package JavaLearn.Method;
import java.util.Scanner;
public class HomeWork {
public static void main(String[] args) {
int a = 0;
int b = 0;
Scanner scanner = new Scanner(System.in);
System.out.println("请输入运算符:");
String operator = scanner.nextLine();
System.out.println("请输入第一个运算数:");
a = scanner.nextInt();
System.out.println("请输入第二个运算数:");
b = scanner.nextInt();
scanner.close();
System.out.println("===============");
switch (operator){
case "+":
System.out.println(a+operator+b+"="+add(a,b));
break;
case "-":
System.out.println(a+operator+b+"="+sub(a,b));
break;
case "*":
System.out.println(a+operator+b+"="+mul(a,b));
break;
case "/":
System.out.println(a+operator+b+"="+div(a,b));
break;
}
}
public static double add(int a,int b){
return a+b;
}
public static double sub(int a,int b){
return a-b;
}
public static double mul(int a,int b){
return a*b;
}
public static double div(int a,int b){
return a/b;
}
}