用 java 定义一个类,定义add、sub、mul、div,分别两个操作数的加减乘除操作(不用用户输入数字)

如题所述

public class MyMath {
public static double add(double m, double n){
return m+n;
}
public static int add(int m, int n){
return m+n;
}
public static double sub(double m, double n){
return m-n;
}
public static int sub(int m, int n){
return m-n;
}
public static double mul(double m, double n){
return m*n;
}
public static int mul(int m, int n){
return m*n;
}
public static double div(double m, double n){
return m/n;
}
public static int div(int m, int n){
return m/n;
}
}

温馨提示:答案为网友推荐,仅供参考
相似回答