Обновить Main.java
This commit is contained in:
parent
4847144f8f
commit
472b422c6e
26
Main.java
26
Main.java
@ -7,8 +7,11 @@ public class Main {
|
|||||||
private int b;
|
private int b;
|
||||||
private int sum;
|
private int sum;
|
||||||
private int mult;
|
private int mult;
|
||||||
|
private int delen;
|
||||||
|
private int vich;
|
||||||
|
|
||||||
Scanner scanner = new Scanner(System.in);
|
Scanner scanner = new Scanner(System.in);
|
||||||
|
|
||||||
public void main(String[] args) {
|
public void main(String[] args) {
|
||||||
while (true) {
|
while (true) {
|
||||||
System.out.println("Введите 1 число: ");
|
System.out.println("Введите 1 число: ");
|
||||||
@ -17,7 +20,7 @@ public class Main {
|
|||||||
System.out.println("Введите 2 число: ");
|
System.out.println("Введите 2 число: ");
|
||||||
int b = scanner.nextInt();
|
int b = scanner.nextInt();
|
||||||
|
|
||||||
System.out.println("Введите нужное действие: \n 1.Сложение \n 2.Умножение \n ");
|
System.out.println("Введите нужное действие: \n 1.Сложение \n 2.Умножение \n 3.Деление \n 4.Вычитание");
|
||||||
int des = scanner.nextInt();
|
int des = scanner.nextInt();
|
||||||
|
|
||||||
|
|
||||||
@ -29,8 +32,16 @@ public class Main {
|
|||||||
int res = mult(a, b);
|
int res = mult(a, b);
|
||||||
System.out.println("Результат: " + res);
|
System.out.println("Результат: " + res);
|
||||||
break;
|
break;
|
||||||
|
} else if (des == 3) {
|
||||||
|
int res = delen(a, b);
|
||||||
|
System.out.println("Результат: " + res);
|
||||||
|
break;
|
||||||
|
} else if (des == 4) {
|
||||||
|
int res = vich(a, b);
|
||||||
|
System.out.println("Результат: " + res);
|
||||||
|
break;
|
||||||
} else {
|
} else {
|
||||||
System.out.println("Введите другое число 1 или 2 ");
|
System.out.println("Введите другое число 1, 2, 3 или 4 ");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -41,9 +52,20 @@ public class Main {
|
|||||||
int sum = a + b;
|
int sum = a + b;
|
||||||
return sum;
|
return sum;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int mult(int a, int b) {
|
public static int mult(int a, int b) {
|
||||||
int mult = a * b;
|
int mult = a * b;
|
||||||
return mult;
|
return mult;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static int delen(int a, int b) {
|
||||||
|
int delen = a / b;
|
||||||
|
return delen;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static int vich(int a, int b) {
|
||||||
|
int vich = a - b;
|
||||||
|
return vich;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Loading…
Reference in New Issue
Block a user