добрый день, есть какое наставление - куда капать или иные комментарии?
надо сделать калькулятор
import java.util.Scanner;
import static java.util.Collections.replaceAll;
import static jdk.internal.net.http.LineSubscriberAdapter.LineSubscription.nextLine;
public class Main {
public static void main(String[] args) {
while (true) {
System.out.println("Введите первое число для расчета");
int a = getNumber();
System.out.println("введите число для расчета");
String operation = getOperation();
System.out.println("Введите второе число для расчета");
int b =getNumber();
switch (operation) {
case "+":
System.out.println(a+b);
break;
case "-":
System.out.println(a-b);
break;
case "*":
System.out.println(a*b);
break;
case "/":
System.out.println(a/b);
break;
default:
System.out.println("Введите корректное значение");
}
}
}
public static int getNumber (){
Scanner sc = new Scanner(System.in);
while (true) {
System.out.println("Введите число");
String maybeNum = sc nextLine();
if (!isNumber(maybeNum)){
System.out.println("не правильный ввод, повторите");
continue;
return Integer.parseInt(maybeNum);
}
}
}
public static boolean isNumber (String a) {
a = a replaceAll("1", "").replaceAll("2", "")
.replaceAll("3", "").replaceAll("4", "")
.replaceAll("5", "").replaceAll("6", "")
.replaceAll("7", "").replaceAll("8", "")
.replaceAll("9", "").replaceAll("0", "")
return a.trim().length==0;
}
public static String getOperation(){
Scanner sc = new Scanner(System.in);
while (true) {
System.out.println("Введите операцию");
String op = sc.nextLine();
if (! isOperation)) {
System.out.println("ошибка ввода- повторите");
continue;
}
return op;
}
}
public static boolean isOperation(String) {
s = s.replaceAll ("+", "")
.replaceAll ("-", "")
.replaceAll ("*", "")
.replaceAll ("/", "")
trim();
return s.length=0;
}
}