-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathConverter.java
More file actions
55 lines (51 loc) · 1.41 KB
/
Converter.java
File metadata and controls
55 lines (51 loc) · 1.41 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
/* Unit Convertor Console App
* 1. Meter Conversion.
* 2. Gram Conversion.
* 3. Temperature Conversion.
* @author : Pradumn Patel (JV Grace)
*/
import java.util.Scanner;
public class Converter{
public static void menu(){
System.out.println("Unit Convertor!");
System.out.println("1.Meter Conversion");
System.out.println("2.Gram Conversion");
System.out.println("3.Temperature Conversion");
System.out.println("4.Exit");
}
public static void main(String[] args){
try (Scanner sc = new Scanner(System.in)) {
boolean chek=false;
while(!chek){
Converter.menu();
System.out.print("Enter Choice : ");
int choice=sc.nextInt();
switch(choice){
case 1->{
System.out.println("Enter Meter Value to Convert to Kilometer: ");
double meter=sc.nextDouble();
System.out.println("The Result: ");
System.out.println(meter+" in meters : "+(meter/1000)+" in kilometers");
}
case 2->{
System.out.println("Enter Gram Value to Convert to Kilogram: ");
double gram=sc.nextDouble();
System.out.println("The Result: ");
System.out.println(gram+" in grams : "+(gram/1000)+" in kilograms");
}
case 3->{
System.out.println("Enter Temperature in C to convert to F: ");
double temp=sc.nextDouble();
System.out.println("The Result: ");
System.out.println(temp+" in C : "+((9/5)*temp+32)+" in F");
}
case 4->{
System.out.println("Exiting!!");
chek=true;}
default->{
System.out.println("Wrong Choice!!");}
}
}
}
}
}