/*3、按要求编写一个Java应用程序: (1)定义一个类,描述一个矩形,包含有长、宽两种属性,和计算面积方法。 (2)编写一个类,继承自矩形类,同时该类描述长方体,具有长、宽、高属性, 和计算体积的方法。 (3)编写一个测试类,对以上两个类进行测试,创建一个长方体,定义其长、 宽、高,输出其底面积和体积。 */ package bbb; import java.util.*; class rectangle{ int length,width; public void count(int length,int width){ int s; s=length*width; System.out.println("面积为:"+s); } } class cuboid extends rectangle{ int high; public void bulk(int length,int width,int high){ int v; v=high*width*length; System.out.println("体积为:"+v); } public static int nextInt() { // TODO 自动生成的方法存根 return 0; } } public class Circle { public static void main(String[]args){ Scanner a=new Scanner(System.in); Scanner b=new Scanner(System.in); Scanner c=new Scanner(System.in); System.out.println("请输入长:"); int length=a.nextInt(); System.out.println("请输入宽:"); int high=b.nextInt(); System.out.println("请输入高:"); int width=c.nextInt(); rectangle s1=new rectangle(); cuboid s2=new cuboid(); s1.count(length,width); s2.bulk(length,width,high); } }