Advertisement
476179

checkTemp-Loops1

Nov 14th, 2019
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.70 KB | None | 0 0
  1. package lessons;
  2. import java.util.Scanner;
  3. public class CheckTemp
  4. {
  5.  
  6. public static void main(String[] args)
  7. {
  8. //check temp, if >102.5 warn its too high to wait then enter a lower temp
  9. // if lower than 102.5 check again in 8 min
  10. Scanner keyboard = new Scanner(System.in);
  11. System.out.println("enter temp:");
  12. double temp = keyboard.nextDouble();
  13.  
  14. final double MAX_TEMP = 102.5;
  15.  
  16. while (temp> MAX_TEMP)
  17. {
  18. System.out.println("too hot, turn thermostat down and wait 5 min then try again:");
  19. System.out.println("enter temp:");
  20. temp = keyboard.nextDouble();
  21. }
  22.  
  23. System.out.println("temp is acceptable, enter again in 15 min");
  24.  
  25. keyboard.close();
  26. }
  27.  
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement