-
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathswitch5.java
More file actions
59 lines (53 loc) · 1.93 KB
/
switch5.java
File metadata and controls
59 lines (53 loc) · 1.93 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
package swichcase;
import java.util.Scanner;
public class switch5 {
public static void main(String[] args) {
Scanner scanner=new Scanner(System.in);
double a,b;
System.out.println("1 -> qo`shish");
System.out.println("2 -> ayrish");
System.out.println("3 -> bo`lish");
System.out.println("4 -> ko`paytirish");
System.out.println("Choose: ");
int choose= scanner.nextInt();
switch (choose){
case 1->{
System.out.println("1- Sonni kiriting:");
a= scanner.nextDouble();
System.out.println("2- Sonni kiriting:");
b=scanner.nextDouble();
int natija= (int) (a+b);
System.out.printf("%d + %d = %d",a,b,natija);
break;
}
case 2->{
System.out.println("1- Sonni kiriting:");
a= scanner.nextDouble();
System.out.println("2- Sonni kiriting:");
b=scanner.nextDouble();
int natija= (int) (a-b);
System.out.printf("%d - %d = %d",a,b,natija);
break;
}
case 3->{
System.out.println("1- Sonni kiriting:");
a= scanner.nextDouble();
System.out.println("2- Sonni kiriting:");
b=scanner.nextDouble();
int natija= (int) (a/b);
System.out.printf("%d / %d = %d",a,b,natija);
}
case 4->{
System.out.println("1- Sonni kiriting:");
a= scanner.nextDouble();
System.out.println("2- Sonni kiriting:");
b=scanner.nextDouble();
int natija= (int) (a*b);
System.out.printf("%d * %d = %d",a,b,natija);
}
default -> {
System.out.println("Noto`g`ri Variant");
}
}
}
}