-
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathswitch13.java
More file actions
80 lines (71 loc) · 2.56 KB
/
switch13.java
File metadata and controls
80 lines (71 loc) · 2.56 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
package swichcase;
import java.util.Scanner;
import static java.lang.System.out;
public class switch13 {
public static void main(String[] args) {
int n;
float x;
float a;
float c;
float h;
float s;
Scanner scanner = new Scanner(System.in);
out.println("==========[Bizda Berilgan]==============");
out.println("1- Teng yonli Uchburchak Kateti");
out.println("2- Teng yonli Uchburchak Gipotenuzasi");
out.println("3- Teng yonli Uchburchak Gipotenuzaga tushurilgan Balandlik");
out.println("4- Teng yonli Uchburchak Yuzasi ");
out.println("==========================================");
out.println("Tanlang :");
int tanlash = scanner.nextInt();
switch (tanlash) {
case 1 -> {
System.out.print("Katet:");
x = scanner.nextFloat();
a = x;
c = (float) (a * Math.sqrt(2));
h = c / 2;
s = c * h / 2;
System.out.printf("Gipotenuza: %.2f\n", c);
System.out.printf("Balandlik: %.2f\n", h);
System.out.printf("Yuza: %.2f\n", s);
}
case 2 -> {
System.out.print("Gipotenuza :");
x = scanner.nextFloat();
c = x;
a = (float) (c / Math.sqrt(2));
h = c / 2;
s = c * h / 2;
System.out.printf("Katet: %.2f\n", a);
System.out.printf("Balandlik: %.2f\n", h);
System.out.printf("Yuza: %.2f\n", s);
}
case 3 -> {
System.out.print("Balandlik :");
x = scanner.nextFloat();
h = x;
c = 2 * h;
a = (float) (c / Math.sqrt(2));
s = c * h / 2;
System.out.printf("Katet: %.2f \n", a);
System.out.printf("Gipotenuza: %.2f \n", c);
System.out.printf("Yuza: %.2f\n", s);
}
case 4 -> {
System.out.print("Yuza :");
x = scanner.nextFloat();
s = x;
h = (float) Math.sqrt(s);
c = 2 * h;
a = (float) (c / Math.sqrt(2));
System.out.printf("Katet: %.2f",a);
System.out.printf("Gipotenuza: %.2f",c);
System.out.printf("Balandlik: %.2f",h);
}
default -> {
out.println("Noto`g`ri Raqam kiritildi !");
}
}
}
}