Skip to content

Commit 8d4ca76

Browse files
committed
Added TempConverter program to lesson 1 demo code.
1 parent ef7ee35 commit 8d4ca76

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
package org.launchcode.java.demos;
2+
3+
import java.util.Scanner;
4+
5+
public class TempConverter {
6+
public static void main(String[] args) {
7+
double fahrenheit;
8+
double celsius;
9+
Scanner input;
10+
11+
input = new Scanner(System.in);
12+
System.out.println("Enter the temperature in Fahrenheit: ");
13+
fahrenheit = input.nextDouble();
14+
input.close();
15+
16+
celsius = (fahrenheit - 32) * 5/9;
17+
System.out.println("The temperature in Celsius is: " + celsius + "°C");
18+
}
19+
}

0 commit comments

Comments
 (0)