-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFahrenheitConverter.java
More file actions
30 lines (22 loc) · 935 Bytes
/
FahrenheitConverter.java
File metadata and controls
30 lines (22 loc) · 935 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
26
27
28
29
30
//FahrenheitConverter.java
import java.util.Scanner; //Needed for the Scanner class
/**
This program converts an entered Fahrenheit degree to Celsius.
*/
public class FahrenheitConverter
{
public static void main(String[] args)
{
double degreesFahrenheit; //Degrees in Fahrenheit entered by the user
double degreesCelsius; //Calculated degrees in celsius
//Create a Scanner object to read input.
Scanner keyboard = new Scanner(System.in);
//Get the degrees in Fahrenheit to be calculated
System.out.print("Enter the degrees in Fahrenheit to be converted into Celsius: ");
degreesFahrenheit = keyboard.nextDouble();
//Calculate Fahrenheit to Celsius
degreesCelsius = ((degreesFahrenheit - 32) * 5)/9;
//Display the resulting information.
System.out.println(degreesFahrenheit + " degrees Fahrenheit is " + degreesCelsius + " degrees Celsius");
}
}