I have had a problem when doing an exercise that asks the user for the number of temperature values taken (it must be greater than 0) and then ask for temperatures and return the number of times it has a value less than zero degrees and the average temperature. Currently I have done so: (Declare all variables as Int).
System.out.println("Introduzca el numero de temperaturas(POSITIVOS)");
temperaturas = entrada.nextInt();
do
{
for (ntemperaturas = 1; ntemperaturas <= temperaturas ; ntemperaturas++)
{
System.out.println("Temperatura numero " + ntemperaturas + ":" );
temperatura = entrada.nextInt();
}
}
while (temperaturas>0);
I would like to know what I am wrong about and how to correct it in order to complete the above statement. Thank you very much!