IntelliEnd @ 2022-12-08 15:43:35
本人代码如下,各位大佬看看本人代码有何问题
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int a = sc.nextInt();
int b = sc.nextInt();
char c = sc.next().charAt(0);
if(b == 0 && c == '/'){
System.out.println("Divided by zero!");
}
if (c == '+') {
System.out.println(a + b);
} else if (c == '-') {
System.out.println(a - b);
} else if (c == '*') {
System.out.println(a * b);
} else if (c == '/') {
System.out.println(a / b);
}else if(c != '+' || c != '-' || c != '*' || c != '/'){
System.out.println("Invalid operator!");
}
}
}
by IceYukino @ 2022-12-08 15:53:31
@IntelliEnd 不懂JAVA语法,你
if(b == 0 && c == '/'){
System.out.println("Divided by zero!");
}
会结束吗?
by ph_chen @ 2023-04-11 17:24:32
6