JAVA编程,用MAIN主方法编程,求三个小数a.b.c的平均值,a.b.c分别为:double a=5.1 b=20.32 c=32.921

来源:百度知道 编辑:UC知道 时间:2024/09/24 08:33:48
急求

public class test {
public static void main(String[] args) {
double a=5.1,b=20.32,c=32.921; //定义变量
double x=(a+b+c)/3; //定义计算结果变量并计算
System.out.println("三个数的平均值为:"+x); //输出结果
}
}

保存时保存为test.java 选择所有文件

public static void main(string args[])
{
double a,b,c,d;
a=5.1;
b=20.32;
c=32.921;
d=(a+b+c)/3
System.out.print("平均值="+d)

}

public static void main(String [] args)
{
double a=5.1,b=20.32,c=32.921;
System.out.println((a+b+c)/3);
}

那么简单,稍稍学习就可以做出来了!!!