-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCheckTemperature.java
41 lines (33 loc) · 1.25 KB
/
CheckTemperature.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
//CheckTemperature.java
import java.util.Scanner;
/**
This program assists a technician in the process
of checking a substance's temperature.
*/
public class CheckTemperature
{
public static void main(String[] args)
{
final double MAX_TEMP = 102.5; // Maximum temperature
double temperature; // To hold the temperature
// Create a Scanner object for keyboard input.
Scanner keyboard = new Scanner(System.in);
// Get he current temperature.
System.out.print("Enter the substance's Celcius temperature: ");
temperature = keyboard.nextDouble();
// As long as necessary, instruct the technician
// to adjust the temperature.
while (temperature > MAX_TEMP)
{
System.out.println("The temperature is too high. Turn the");
System.out.println("thermostat down and wait 5 minutes.");
System.out.println("Then, take the Celcius temperature again");
System.out.println("and enter it here: ");
temperature = keyboard.nextDouble();
}
// Remind the technician to check the temperature
// agin in 15 minutes
System.out.println("The temperature is acceptable.");
System.out.println("Check it again in 15 minutes.");
}
}