forked from AdeshTikande/Basic-Java-Program-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDegree.java
More file actions
27 lines (26 loc) · 1.08 KB
/
Copy pathDegree.java
File metadata and controls
27 lines (26 loc) · 1.08 KB
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
import java.util.Scanner;
public class Degree {
public static void main(String args[]) {
Scanner sc =new Scanner(System.in);
System.out.println("1. Degree Celsius to Fahrenheit");
System.out.println("2. Degree Fahrenheit to Celsius");
System.out.println("Enter your choice");
int choice = sc.nextInt();
switch(choice) {
case 1:
System.out.println("Enter the temperature in Celsius");
double celsius = sc.nextDouble();
double fahrenheit = (celsius * 9/5) + 32;
System.out.println("Temperature in Fahrenheit: " + fahrenheit);
break;
case 2:
System.out.println("Enter the temperature in Fahrenheit");
double fahrenheit1 = sc.nextDouble();
double celsius1 = (fahrenheit1 - 32) * 5/9;
System.out.println("Temperature in Celsius: " + celsius1);
break;
default:
System.out.println("Invalid choice");
}
}
}