Обновить Main.java
This commit is contained in:
parent
4847144f8f
commit
472b422c6e
46
Main.java
46
Main.java
@ -2,48 +2,70 @@ package org.volkova;
|
||||
|
||||
import java.util.Scanner;
|
||||
|
||||
public class Main {
|
||||
public class Main {
|
||||
private int a;
|
||||
private int b;
|
||||
private int sum;
|
||||
private int mult;
|
||||
private int delen;
|
||||
private int vich;
|
||||
|
||||
Scanner scanner = new Scanner(System.in);
|
||||
|
||||
public void main(String[] args) {
|
||||
while (true){
|
||||
while (true) {
|
||||
System.out.println("Введите 1 число: ");
|
||||
int a = scanner.nextInt();
|
||||
|
||||
System.out.println("Введите 2 число: ");
|
||||
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();
|
||||
|
||||
|
||||
if (des == 1 ){
|
||||
int res = plus(a,b);
|
||||
if (des == 1) {
|
||||
int res = plus(a, b);
|
||||
System.out.println("Результат: " + res);
|
||||
break;
|
||||
}else if (des == 2){
|
||||
int res = mult(a,b);
|
||||
} else if (des == 2) {
|
||||
int res = mult(a, b);
|
||||
System.out.println("Результат: " + res);
|
||||
break;
|
||||
}else{
|
||||
System.out.println("Введите другое число 1 или 2 ");
|
||||
} 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 {
|
||||
System.out.println("Введите другое число 1, 2, 3 или 4 ");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static int plus(int a, int b){
|
||||
public static int plus(int a, int b) {
|
||||
int sum = a + b;
|
||||
return sum;
|
||||
}
|
||||
public static int mult (int a, int b){
|
||||
|
||||
public static int mult(int a, int b) {
|
||||
int mult = a * b;
|
||||
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