-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTemperature.java
More file actions
25 lines (22 loc) · 981 Bytes
/
Temperature.java
File metadata and controls
25 lines (22 loc) · 981 Bytes
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
//******************************************************************************
// Filename: Temperature.java
//
// Author: David C. Drake (https://davidcdrake.com)
//
// Description: Temperature class for converting Fahrenheit to Celsius.
//******************************************************************************
import java.io.*;
public class Temperature {
public static void main(String[] args) throws IOException {
final double BASE = 32;
final double CONVERSION_FACTOR = 5.0 / 9.0;
BufferedReader stdin = new BufferedReader(new InputStreamReader(System.in));
double tempF, tempC;
System.out.print("Enter temperature in Fahrenheit: ");
tempF = Double.parseDouble(stdin.readLine());
System.out.println("User entered: " + tempF + " degrees F");
System.out.println((tempF - BASE) + " degrees F above freezing.");
tempC = CONVERSION_FACTOR * (tempF - BASE);
System.out.println("Temperature in Celsius: " + tempC);
}
}