用Java实现求以下数值的平均值然后开方:int1 = 5; int2 = 7 ;int3 = 4; int4 = 25 ;int5 = 13 。
要求输出为:averageofnumbersis10.8squarerootofaverageis3.286335345030997初学者不太懂,谢谢!...
要求输出为:average of numbers is 10.8
square root of average is 3.286335345030997
初学者不太懂,谢谢! 展开
square root of average is 3.286335345030997
初学者不太懂,谢谢! 展开
2个回答
展开全部
public class Avg {
/**
* @param args
*/
public static void main(String[] args) {
int int1 = 5;
int int2 = 7;
int int3 = 4;
int int4 = 25;
int int5 = 13;
double averge = (double)(int1 + int2 + int3 + int4 + int5) / 5;
double sqrt = Math.sqrt(averge);
System.out.println("average of numbers is " + averge);
System.out.println("square root of average is " + sqrt);
}
}
/**
* @param args
*/
public static void main(String[] args) {
int int1 = 5;
int int2 = 7;
int int3 = 4;
int int4 = 25;
int int5 = 13;
double averge = (double)(int1 + int2 + int3 + int4 + int5) / 5;
double sqrt = Math.sqrt(averge);
System.out.println("average of numbers is " + averge);
System.out.println("square root of average is " + sqrt);
}
}
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询