Skip to content

Commit dc816a6

Browse files
committed
feat: Add Temperature class to convert Celsius to Fahrenheit
Add a program that: - Takes temperature input in Celsius from the user - Converts it to Fahrenheit using the formula (C × 9/5) + 32 - Demonstrates basic arithmetic operations and input handling with `Scanner`.
1 parent 92b0a05 commit dc816a6

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

Section5OperatorExpression/src/Temperature.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,10 @@ public class Temperature {
44
public static void main(String[] args) {
55
Scanner in = new Scanner(System.in);
66
System.out.print("Please enter temp in C: ");
7+
78
float tempC = in.nextFloat();
9+
10+
//converting temp into the F.
811
float tempF = (tempC * 9/5) + 32;
912
System.out.println(tempF);
1013
}

0 commit comments

Comments
 (0)