-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCelciusTempConvert.java
More file actions
40 lines (26 loc) · 1.15 KB
/
CelciusTempConvert.java
File metadata and controls
40 lines (26 loc) · 1.15 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
import java.util.Scanner;
public class CelciusTempConvert
{
//-----------------------------------------------------------------
// Computes the Fahrenheit equivalent of a specific Celsius
// value using the formula F = (9/5)C + 32.
// Compute Fahrenheit to Celcius prompt user to enter Fahrenheit
// Formula C = (F - 32) * 5/9
//-----------------------------------------------------------------
public static void main(String[] args)
{
final int BASE = 32;
final double CONVERSION_FACTOR = 9.0 / 5.0;
double fahrenheitTemp;
double celciusTemp;
Scanner myTemp = new Scanner(System.in);
System.out.print("Enter Fahrenheit:");
fahrenheitTemp = myTemp.nextDouble();
//System.out.print("Enter Celcius:");
//celciusTemp = myTemp.nextDouble();
celciusTemp = (fahrenheitTemp - BASE) * (5.0/9.0);
//fahrenheitTemp = celciusTemp * CONVERSION_FACTOR + BASE;
System.out.println("Celcius Equivalent:" + celciusTemp);
//System.out.println("Fahrenheit Equivalent:" + fahrenheitTemp);
}
}