- Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathCase7.java
34 lines (31 loc) · 1.2 KB
/
Case7.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
importjava.util.Scanner;
publicclassCase7 {
// berilgan
// og'irlik
// birlik
// kg ga o'tkazilsin
publicstaticvoidmain(String[] args) {
Scannerscanner = newScanner(System.in);
doubleweight;
intbirlik;
System.out.println("Kg ga convert");
System.out.println("w = ");
weight = scanner.nextDouble(); //12.5
System.out.println("Birlikni tanlang");
System.out.println("1:kg 2:mg, 3:gr, 4:tn 5:sr ");
birlik = scanner.nextInt();
// 1. kg 2.mg, 3.gr, 4.tn 5.sr
switch (birlik) {
case1 -> // kg
System.out.printf("%f(kg) -> %f(kg)", weight, weight);
case2 -> // mg 1kg = 1000000 mg
System.out.printf("%f(mg) -> %f(kg)", weight, (weight / 1_000_000L));
case3 -> // gr 1kg = 1000 gr
System.out.printf("%f(gr) -> %f(kg)", weight, (weight / 1_000L));
case4 -> // tn 1tn = 1000 kg
System.out.printf("%f(tn) -> %f(kg)", weight, weight * 1000);
case5 -> // sr 1sr = 100 kg
System.out.printf("%f(sr) -> %f(kg)", weight, weight * 100);
}
}
}