Im trying to get this program to only print the numbers greater then 18 but I am abit confused on where to put the if ( temperature < 18) if you get me , I am only new to java and any help would be appreciated.
import java.util.Scanner;
class L2TemperatureReading
{
public static void main (String[] args)
{
Scanner input = new Scanner (System.in);
double temperature[]=new double[7];
for(int i=0; i<temperature.length; i++)
{
System.out.print("Max temperature for day " + (i+1) + ": ");
temperature [i] = input.nextDouble();
}
System.out.println("**The temperatures entered**\n");
System.out.println("The temperautures entered are as follows: \n");
for(int i=0; i<temperature.length; i++)
{
System.out.println("Day " +i+ " = " + temperature [i]);
}
}
}
Aucun commentaire:
Enregistrer un commentaire