标题: 简易版,计算器,大家凑活着看看 [打印本页] 作者: Morrfree 时间: 2015-8-7 22:55 标题: 简易版,计算器,大家凑活着看看 /*
需求: 简易版计算器
*/
class MyMath{
public double myMathJia(int x,int y){//传入int类型运算时自动提升为double类型
return x + y;
}
public double myMathJian(double x,double y){
return x - y;
}
public double myMathCheng(double x,double y){
return x*y;
}
public double myMathChu(double x,double y){
return x/y;
}
}
// 测试类
class TestMyMath{
public static void main(String[] args){
MyMath m = new MyMath();
double a = m.myMathJia(56,89);
double b = m.myMathJian(56,89);
double c = m.myMathCheng(56,89);
double d = m.myMathChu(56,89);
System.out.println("加法"+a+"减法"+b+"乘法"+c+"除法"+d);