【输入形式】无
【输出形式】
Round Table Area =7850.0
Rect Table Area=2400.0
public class Test{
public static void main(String[] args)
{
int r = 50;
int width = 40;
int len = 60;
double roundArea = 0;
double rectArea = 0;
TableInfo roundTable = new TableInfo("Round", 4, 100);
TableInfo rectTable = new TableInfo("Rect", 4, 100);
System.out.println("Round Table Area =" + roundTable.tableArea(r));
System.out.println("Rect Table Area=" + rectTable.tableArea(width, len));
}
}
class TableInfo{
String shape;
int legs;
int hight;
public TableInfo(String shape, int legs,int hight){
this.shape = shape;
this.legs = legs;
this.hight = hight;
}
public void print(){
System.out.println("Shape=" + shape);
}
public double tableArea(double r){
return 3.14*r*r;
}
public double tableArea(int a,int b)
{
return a*b;
}
}