-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtask3.java
More file actions
61 lines (48 loc) · 1.42 KB
/
task3.java
File metadata and controls
61 lines (48 loc) · 1.42 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
import java.util.Scanner;
public class task3 {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.println("Введите число: ");
int a = sc.nextInt();
System.out.println("Введите число: ");
int b = sc.nextInt();
System.out.println("Введите опирацию: (1 - умножение: 2 - деление: 3 - разность: 4 - сложение) ");
int op = sc.nextInt();
sc.close();
if (op == 1){
int res = Mult(a, b);
System.out.println(res);
}
else if (op == 2){
int res = Div(a, b);
System.out.println(res);
}
else if (op == 3){
int res = Sub(a, b);
System.out.println(res);
}
else if (op == 4){
int res = Sum(a, b);
System.out.println(res);
}
else{
System.out.println("введите существующую операцию");
}
}
public static int Sum(int a, int b){
int c = a + b;
return c;
}
public static int Mult(int a, int b){
int c = a * b;
return c;
}
public static int Div(int a, int b){
int c = a / b;
return c;
}
public static int Sub(int a, int b){
int c = a - b;
return c;
}
}