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