package 练习;
import java.util.Scanner;
public 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 MyMathText{
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));
}
}