Evening everyone. Had a quick question about a sentinel loop. Ideally I want the program to terminate as soon as the user enters "-9999".
I've got it to the point where the loop will end EVENTUALLY after user enters "-9999", but the "Enter the Wind Velocity" Prompt still comes up after the user enters the sentinel -9999. I want the program to end immediately upon receiving the sentinel - I don't want any more prompts after receiving the sentinel.
I don't know, but Good Lord I've spent the entire day trying to figure out just this last piece of the program. I'm at a loss and would really appreciate any advice I can get. Below is what I have so far. Please, I'll take anything!!!!
import java.util.*;
public class windChill999 {
public static void main(String[] args) {
Scanner console = new Scanner(System.in);
double x;
do{
System.out.printf("Enter the temperature Degrees Fahrenheit (Enter -9999 to stop): ");
double tempF = console.nextDouble();
x = tempF;
System.out.printf("Enter the Wind Velocity (MPH): ");
double velocityMPH = console.nextDouble();
double chillTemp = 35.74 + 0.6215*tempF - 35.75*Math.pow(velocityMPH, 0.16) +
0.4275*tempF*Math.pow(velocityMPH, 0.16);
System.out.printf("The wind chill for temp (degrees F) = %6.1f", tempF);
System.out.printf(" and wind velocity (MPH) = %6.1f", velocityMPH);
System.out.printf(" is = %6.1f degress fahrenheit\n", chillTemp);
}while(x != -9999);
}
}
