public static void main(String[] args) {
Shape shape;
Scanner input = new Scanner(System.in);
System.out.println("请选择图形(1、圆形 2、矩形 3、三角形)");
int a = input.nextInt();
if(a == 1){
System.out.println("请输入圆形的边长:");
double r = input.nextDouble();
shape = new Round(r);
shape.area();
}else if(a == 2){
System.out.println("请输入矩形的底:");
double bottom = input.nextDouble();
System.out.println("请输入矩形的高:");
double high = input.nextDouble();
shape = new Rectangle(bottom, high);
shape.area();
}else if(a == 3){
System.out.println("请输入三角形的底:");
double bottom = input.nextDouble();
System.out.println("请输入三角形的高:");
double high = input.nextDouble();
shape = new Triangle(bottom, high);
shape.area();
}
input.close();

}

相关文章:

  • 2022-12-23
  • 2022-02-23
  • 2022-12-23
  • 2022-12-23
  • 2021-11-26
  • 2022-12-23
  • 2021-07-29
  • 2021-05-23
猜你喜欢
  • 2021-11-29
  • 2021-07-12
  • 2022-02-07
  • 2021-09-19
  • 2022-12-23
  • 2021-08-06
  • 2021-09-18
相关资源
相似解决方案