圖片
class ChongZai{
public double area(double radius){
return (Math.PI*radius*radius);
}
public double area(double length,double width){
return (length*width);
public double area(double length,double width,double height){
return ( length*width*height);
public class A{
public static void main(String args[]){
ChongZai t=new ChongZai();
System.out.println("圓的半徑為5,面積是:"+t.area(5));
System.out.println("矩形長為6,寬為21,面積是:"+t.area(6,21));
System.out.println("立方體長寬高分別為4,5,6,面積是:"+t.area(4,5,6));
圖片
class ChongZai{
public double area(double radius){
return (Math.PI*radius*radius);
}
public double area(double length,double width){
return (length*width);
}
public double area(double length,double width,double height){
return ( length*width*height);
}
}
public class A{
public static void main(String args[]){
ChongZai t=new ChongZai();
System.out.println("圓的半徑為5,面積是:"+t.area(5));
System.out.println("矩形長為6,寬為21,面積是:"+t.area(6,21));
System.out.println("立方體長寬高分別為4,5,6,面積是:"+t.area(4,5,6));
}
}