源代码
import java.util.Scanner;
class Demo3 {
public int computer(int a, int b, char c){
switch (c){
case '+':
return (a+b);
case '-':
return a-b;
case '*':
return a*b;
case '/':
return a/b;
case '%':
return a%b;
default:
return 000;
}
}
}
public class Text3 {
public static void main(String[] args) {
Demo3 demo3 = new Demo3();
System.out.println("请输入第一位数字");
Scanner scanner = new Scanner(System.in);
int i = scanner.nextInt();
System.out.println("请输入第二位数字");
int i1 = scanner.nextInt();
System.out.println("请输入你的符号");
char c = scanner.next().charAt(0);
int computer = demo3.computer(i, i1, c);
System.out.println("你要的结果是"+computer);
}
}