package com.tedu;
import java.util.Scanner;
// 接管用户输出的两个 int 类型数值
// 依照用户输出 1,2,3,4,别离执行相应的 +-*/ 办法 将最初的后果输入至控制台。public class Test08 {public static void main(String[] args) {System.out.println("请输出第一个数字");
int a = new Scanner(System.in).nextInt();
System.out.println("请输出第二个数字");
int b = new Scanner(System.in).nextInt();
System.out.println("请输出要执行的运算");
int c = new Scanner(System.in).nextInt();
if (c==1){add(a,b);
}else if (c==2){substruction(a,b);
}else if(c==3){multiplication(a,b);
}else if(c==4){division(a,b);
}
}
private static void division(int a, int b) {
int sum=a/b;
System.out.println("sum =" + sum);
}
private static void multiplication(int a, int b) {
int sum=a*b;
System.out.println("sum =" + sum);
}
private static void substruction(int a, int b) {
int sum = a-b;
System.out.println("sum =" + sum);
}
private static void add(int a, int b) {
int sum=a+b;
System.out.println("sum =" + sum);
}
}