-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUnitconverter.java
More file actions
119 lines (112 loc) · 2.73 KB
/
Unitconverter.java
File metadata and controls
119 lines (112 loc) · 2.73 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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
import java.util.*;
public class Unitconverter
{
public static void main(String[] args)
{
System.out.println("Welcome to THE Unit Converter");
System.out.println("Select desired Quantity");
System.out.println("");
System.out.println("1 : Length");
System.out.println("2 : Weight");
System.out.println("3 : Tempreture");
Scanner check = new Scanner(System.in);
int q=check.nextInt();
switch(q)
{
case 1:
{
length(q);
} break;
case 2:
{
System.out.println("Weight");
} break;
case 3:
{
System.out.println("Temp");
} break;
}
}
public static int length (int q)
{
System.out.println("Choose the Quantity to convert");
System.out.println("");
System.out.println("1 : Meters");
System.out.println("2 : Centimeters");
System.out.println("3 : Kilometers");
Scanner check = new Scanner(System.in);
int i=check.nextInt();
switch(i)
{
case 1:
{
System.out.println("Enter the Length in Meters");
} break;
case 2:
{
System.out.println("Enter the Length in Centimeters");
} break;
case 3:
{
System.out.println("Enter the Length in Kilometers");
} break;
}
float l1=check.nextInt();
System.out.println("Choose the Quantity to convert to");
System.out.println("");
System.out.println("1 : Meters");
System.out.println("2 : Centimeters");
System.out.println("3 : Kilometers");
int f = check.nextInt();
float l2=0;
if(i==1)
{
switch(f)
{
case 2:
{
l2=l1*100;
System.out.println("After conversion the length is :" +l2);
} break;
case 3:
{
l2=l1/1000;
System.out.println("After conversion the length is :" +l2);
} break;
}
}
if(i==2)
{
switch(f)
{
case 1:
{
l2=l1/100;
System.out.println("After conversion the length is :" +l2);
} break;
case 3:
{
l2=l1/100000;
System.out.println("After conversion the length is :" +l2);
} break;
}
}
if(i==3)
{
switch(f)
{
case 1:
{
l2=l1*1000;
System.out.println("After conversion the length is :" +l2);
} break;
case 2:
{
l2=l1*100000;
System.out.println("After conversion the length is :" +l2);
} break;
}
}
return 0;
}
}