We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents 91b72ad + 6a44034 commit baf6319Copy full SHA for baf6319
ch03/CelsiusToFahrenheit.java
@@ -0,0 +1,28 @@
1
+import java.util.Scanner;
2
+
3
+public class CelsiusToFahrenheit {
4
5
+ public static void main(String[] args) {
6
+ // Create variables
7
+ double celsius;
8
+ double fahrenheit;
9
+ final int FREEZING_TEMP = 32;
10
+ Scanner input = new Scanner(System.in);
11
12
+ // Ask for number in celsius, then save that input as the celsius variable
13
+ System.out.print("Enter a temperature in Celsius: ");
14
+ celsius = input.nextDouble();
15
+ System.out.printf("%.1f celsius\n", celsius);
16
17
+ // Conver celsius to fahrenheit
18
+ fahrenheit = (celsius * 9.0/5.0) + (FREEZING_TEMP);
19
20
+ // Display result!
21
+ System.out.printf("%.1f celsius = %.1f fahrenheit\n", celsius, fahrenheit);
22
23
24
25
+ }
26
27
28
+}
0 commit comments