-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathE511.java
More file actions
48 lines (39 loc) · 1.56 KB
/
Copy pathE511.java
File metadata and controls
48 lines (39 loc) · 1.56 KB
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
42
43
44
45
46
47
48
package Hw3;
import java.util.Scanner;
public class E511 {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
final int BOIL_TEMPERATURE_AT_CELSIUS = 100;
final int SOLID_TEMPERATURE_AT_CELSIUS = 0;
final int BOIL_TEMPERATURE_AT_FAHRENHEIT = 212;
final int SOLID_TEMPERATURE_AT_FAHRENHEIT = 32;
System.out.println("Please enter temperature: ");
int temperature = in.nextInt();
System.out.println("Please enter C for Celsius or F for Fahrenheit: ");
char letter = in.next().toUpperCase().charAt(0);
if (letter == 'C') {
if (temperature < 0) {
System.out.println("Solid");
}
else if (temperature >= SOLID_TEMPERATURE_AT_CELSIUS
&& temperature <= BOIL_TEMPERATURE_AT_CELSIUS) {
System.out.println("Liquid");
}
else if (temperature > BOIL_TEMPERATURE_AT_CELSIUS) {
System.out.println("Gaseous");
}
}
else if (letter == 'F') {
if (temperature <= SOLID_TEMPERATURE_AT_FAHRENHEIT) {
System.out.println("Solid");
}
else if (temperature > SOLID_TEMPERATURE_AT_FAHRENHEIT
&& temperature < BOIL_TEMPERATURE_AT_FAHRENHEIT) {
System.out.println("Liquid");
}
else if (temperature >= BOIL_TEMPERATURE_AT_FAHRENHEIT) {
System.out.println("Gaseous");
}
}
}
}