-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUnitConverter.java
More file actions
53 lines (41 loc) · 1.65 KB
/
Copy pathUnitConverter.java
File metadata and controls
53 lines (41 loc) · 1.65 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
import java.util.Scanner;
public class UnitConverter {
public static void centimetertoinch() {
System.out.println("Please enter value of centimeter:");
Scanner scanner = new Scanner(System.in);
double inputtedNum = scanner.nextDouble();
System.out.println("Answer: " + inputtedNum / 2.54);
}
public static void KGtoPound() {
System.out.println("Please enter value of Kilogram:");
Scanner scanner = new Scanner(System.in);
double inputtedNum = scanner.nextDouble();
System.out.println("Answer:" + inputtedNum * 2.205);
}
public static void celciustoferenheit() {
System.out.println("Please enter value of Celcius: ");
Scanner scanner = new Scanner(System.in);
double inputtedNUM = scanner.nextDouble();
System.out.println("Answer:" + inputtedNUM * 9 / 5 + 32);
}
public static void main(String[] args) {
while (true) {
System.out.println("Option 1 : Kilogram - Pound");
System.out.println("Option 2 : Celcius - Ferenheit");
System.out.println("Option 3 : Centimeter - inch");
String option = "Option:";
System.out.println(option);
Scanner scanner = new Scanner(System.in);
String inputtedString = scanner.next();
if (inputtedString.equals("1")) {
KGtoPound();
}
if (inputtedString.equals("2")) {
celciustoferenheit();
}
if (inputtedString.equals("3")) {
centimetertoinch();
}
}
}
}