作业帮 > 综合 > 作业

java定义一个实现常用数学运算的类MyMath,类中提供max().min().sum()与average()

来源:学生作业帮 编辑:灵鹊做题网作业帮 分类:综合作业 时间:2024/04/30 05:05:10
java定义一个实现常用数学运算的类MyMath,类中提供max().min().sum()与average()
定义一个实现常用数学运算的类MyMath,类中提供max().min().sum()与average()四个静态方法,每个方法带有三个整形参数,分别实现对三个整数求取最大值·最小值·和值及平均值的运算.在主类中对任意输入的三个整数,调用MyMath类的四种静态方法,求取结果并输出.
java定义一个实现常用数学运算的类MyMath,类中提供max().min().sum()与average()
public class MyMath{
private static void max(int x,int y,int z){
if(x>y){
if(x>z){
System.out.println("最大数是X:"+x);
}
else{
System.out.println("最大数是Z:"+z);
}
}
else{
if(y>z){
System.out.println("最大数是y:"+y);
}
else{
System.out.println("最大数是Z:"+z);
}
}
}
private static void min(int x,int y,int z){
if(x