编写一个java程序,要求使用方法重载计算半径为10的圆面积与边长为5的正方形面积。
3 回答
望远
TA贡献1017条经验 获得超1032个赞
public class imooc {
private float area(float n){
return (float) (Math.PI*n*n);
}
private float area(float n,float m){
return n*m;
}
public static void main(String[] args) {
float s;
imooc test = new imooc();
s=test.area(10);
System.out.println("半径为10的圆的面积为:"+s);
s=test.area(5,5);
System.out.println("边长为5的正方形的面积为:"+s);
}
}添加回答
举报
0/150
提交
取消
