Мой первый коммит
This commit is contained in:
commit
4847144f8f
49
Main.java
Normal file
49
Main.java
Normal file
@ -0,0 +1,49 @@
|
|||||||
|
package org.volkova;
|
||||||
|
|
||||||
|
import java.util.Scanner;
|
||||||
|
|
||||||
|
public class Main {
|
||||||
|
private int a;
|
||||||
|
private int b;
|
||||||
|
private int sum;
|
||||||
|
private int mult;
|
||||||
|
|
||||||
|
Scanner scanner = new Scanner(System.in);
|
||||||
|
public void main(String[] args) {
|
||||||
|
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 ");
|
||||||
|
int des = scanner.nextInt();
|
||||||
|
|
||||||
|
|
||||||
|
if (des == 1 ){
|
||||||
|
int res = plus(a,b);
|
||||||
|
System.out.println("Результат: " + res);
|
||||||
|
break;
|
||||||
|
}else if (des == 2){
|
||||||
|
int res = mult(a,b);
|
||||||
|
System.out.println("Результат: " + res);
|
||||||
|
break;
|
||||||
|
}else{
|
||||||
|
System.out.println("Введите другое число 1 или 2 ");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public static int plus(int a, int b){
|
||||||
|
int sum = a + b;
|
||||||
|
return sum;
|
||||||
|
}
|
||||||
|
public static int mult (int a, int b){
|
||||||
|
int mult = a * b;
|
||||||
|
return mult;
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue
Block a user