Mi chiedevo se qualcuno potesse aiutarmi a trovare il valore massimo di un insieme di variabili e assegnarle a un'altra variabile. Ecco uno snippet del mio codice che può aiutare a capire di cosa sto parlando.Come trovare il valore massimo del set di variabili
// Ask for quarter values.
System.out.println("What is the value of the first quarter?");
firstQuarter = input.nextDouble();
System.out.println("What is the value of the second quarter?");
secondQuarter = input.nextDouble();
System.out.println("What is the value of the third quarter?");
thirdQuarter = input.nextDouble();
System.out.println("What is the value of the fourth quarter?");
fourthQuarter = input.nextDouble();
//Tell client the maximum value/price of the stock during the year.
//maxStock = This is where I need help
System.out.println("The maximum price of a stock share in the year is: $" + maxStock + ".");
mi scuso ho pensato che questo era sotto il forum Java o qualcosa del genere. –
@CodyBennett Nessun problema. Ho aggiunto il tag Java per te.Potrebbe essere utile ottenere più risposte se stai cercando una risposta diversa. – nybbler
Questa soluzione è interrotta come scritto. Double.MIN_VALUE restituisce "il più piccolo valore positivo diverso da zero del tipo double", che è un numero molto vicino a 0, NON il più grande doppio negativo possibile. Invece, potrebbe essere usato qualcosa come Double.NEGATIVE_INFINITY o -Double.MAX_VALUE. – ulmangt