hey guys,
I have this program that calculates the wind chill temp, But I have a little problem. The air temperature tAir
should be less than 10 and the wind speed wSpeed
should be over 5. So I need to keep asking for a new input from the user UNTIL i get a valid number. The way I did it, it only asks them twice (repeats twice) and that's it.
How can I keep asking until get an valid value? Here is that section of the program:
System.out.println("Please enter the air temperature");
tAir = keyboard.nextInt(); // outside temperature
if (tAir>10);
{System.out.println("Error in air temperature (too high):" + tAir);
System.out.println("Please enter the air temprature");
tAir = keyboard.nextInt(); }
System.out.println("Please enter the wind speed:");
wSpeed = keyboard.nextInt(); // wind-speed
if ( wSpeed < 5)
{ System.out.println("Error in the wind speed (too low):" +wSpeed);
System.out.println("please enter the wind speed");
wSpeed = keyboard.nextInt();
}
else
{
twc = windChill(tAir,wSpeed);