Guest User

Untitled

a guest
Jul 10th, 2021
230
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.28 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. /**
  4. This program asists a technician in the process
  5. of checking a substance's temperature.
  6. */
  7. public class CheckTemperature
  8. {
  9. public static void main(String[] args)
  10. {
  11. final double MAX_TEMP = 102.5; // Maximum temperature
  12. double temperature; // To hold the temperature
  13.  
  14. // Create a Scanner object for keyboard input.
  15. Scanner keyboard = new Scanner(System.in);
  16.  
  17. // Get the current temperature.
  18. System.out.print("Enter the substance's Celsius temperature: ");
  19. temperature = keyboard.nextDouble();
  20.  
  21. // As long as necessary, instruct the technician
  22. // to adjust the temperature.
  23. while (temperature > MAX_TEMP)
  24. {
  25. System.out.println("The temperature is too high. Turn the");
  26. System.out.println("thermostat down and wait 5 minutes.");
  27. System.out.println("Then, take the Celsius temperature again");
  28. System.out.print("and enter it here: ");
  29. temperature = keyboard.nextDouble();
  30. }
  31.  
  32. // Remind the technician to check the temperature
  33. // again in 15 minutes.
  34. System.out.println("The temperature is acceptable.");
  35. System.out.println("Check it again in 15 minutes.");
  36. }
  37. }
  38.  
Advertisement
Add Comment
Please, Sign In to add comment