import java.util.Scanner;
class MyMath{
public int add(int a,int b){
return a + b;
}
public int sub(int a,int b){
return a - b;
}
public int mul(int a,int b){
return a * b;
}
public int div(int a,int b){
return a / b;
}
}
class MyMathTest{
public static void main(String[] args){
//创建键盘录入对象
Scanner sc = new Scanner(System.in);
System.out.println("请输入第一个操作数:");
int firstNumber = sc.nextInt();
System.out.println("请输入第二个操作数:");
int secondNumber = sc.nextInt();
//创建MyMath对象并使用
MyMath mm = new MyMath();
System.out.println("加法结果:" + mm.add(firstNumber,secondNumber));
System.out.println("减法结果:" + mm.sub(firstNumber,secondNumber));
System.out.println("乘法结果:" + mm.mul(firstNumber,secondNumber));
System.out.println("除法结果:" + mm.div(firstNumber,secondNumber));
}
}
运行结果截图: