-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTemp.java
35 lines (34 loc) · 1.01 KB
/
Temp.java
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
import java.util.*;
public class Temp {
public void FarToCel(){
Scanner sc=new Scanner(System.in);
System.out.println("Enter temperature:");
double a=sc.nextInt();
double res=5*(a-32)/9;
System.out.println("Temperature in celcius is :"+res);
sc.close();
}
public void CelToFar(){
Scanner sc=new Scanner(System.in);
System.out.println("Enter temperature:");
double a=sc.nextInt();
double res=(9*a-160)/5;
System.out.println("Temperature in farenhiet is :"+ res);
sc.close();
}
public static void main(String[] args) {
Temp fun=new Temp();
Scanner sc=new Scanner(System.in);
System.out.println("Select any one of two:\n1.Farenhiet to celcius\n2.Celcius to Farenhiet");
int b=sc.nextInt();
switch(b){
case 1:
fun.FarToCel();
break;
case 2:
fun.CelToFar();
break;
}
sc.close();
}
}