-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTemperatureCalc.java
More file actions
56 lines (55 loc) · 2.44 KB
/
Copy pathTemperatureCalc.java
File metadata and controls
56 lines (55 loc) · 2.44 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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#This Java program converts temperatures between Celsius, Kelvin, and Fahrenheit based on user input.
import java.util.Scanner;
public class TemperatureCalc{
public static void main(String[] args){
System.out.println("\t\tTemperature calculator");
System.out.println("1.Centegrade to Kelvin\n2.Kelvin to Centegrade\n3.Centegrade to Farenhiet\n4.Farenhiet to Centegrade\n5.Farenhiet to Kelvin\n6.Kelvin to Farenhiet");
System.out.println("Select the conversion ");
Scanner Hel= new Scanner(System.in);
int k= Hel.nextInt();
switch(k){
case 1:{
System.out.println("Enter the Temperature in Centegrade ");
float i=Hel.nextFloat();
float l=i+ 273.15f;
System.out.print("Temperature in Kelvin is: ");
System.out.println(l);
break ;}
case 2:{
System.out.println("Enter the Temperature in Kelvin ");
float i=Hel.nextFloat();
float l=i-273.15f;
System.out.print("Temperature in Centegrade is: ");
System.out.println(l);
break ;}
case 3:{
System.out.println("Enter the Temperature in Centegrade ");
float i=Hel.nextFloat();
float l=(i* 9/5) + 32;
System.out.print("Temperature in Farenhiet is: ");
System.out.println(l);
break ;}
case 4:{
System.out.println("Enter the Temperature in Farenhiet");
float i=Hel.nextFloat();
float l=(i- 32)* 5/9;
System.out.print("Temperature in Centigrade is: ");
System.out.println(l);
break ;}
case 5:{
System.out.println("Enter the Temperature in Farenhiet ");
float i=Hel.nextFloat();
float l=((i-32)* 5/9)+273.15f;
System.out.print("Temperature in Kelvin is: ");
System.out.println(l);
break ;}
case 6:{
System.out.println("Enter the Temperature in Kelvin ");
float i=Hel.nextFloat();
float l=((i-273.15f)*9/5)+32;
System.out.print("Temperature in Farenhiet is: ");
System.out.println(l);
break ;}
}
}
}