package aaaaa;
public class JUxin { private double len; private double wen;
public double getlength() {
return len; }
public double getwidth() {
return wen; }
public double squre() {
return this.len*this.wen; }
public void setlen(double len){
this.len=len; }
public void setwen(double wen){ this.wen=wen; }
}
-------------------------------------------------------------------------------------
package aaaaa;
public class tsss extends JUxin{
private double height;
public double getHeight() {
return height; }
public void setHeight(double height) {
this.height = height; }
public double tiji() {
return this.getlength()*this.getHeight()*this.getwidth(); }
}
-------------------------------------------------------------------------------------
package aaaaa;
import java.util.Scanner;
public class emmm {
public static void main(String[] args) {
JUxin j= new JUxin();
Scanner in = new Scanner(System.in);
System.out.println("intput length:");
double length =in.nextDouble();
System.out.println("intput wide:");
double wide=in.nextDouble();
System.out.println("intput height:");
double height= in.nextDouble();
j.setlen(length);
j.setwen(wide);
System.out.println("矩形的长为:"+j.getlength()+" 宽为:"+j.getwidth());
System.out.println("矩形的面积为:"+j.squre());
tsss c = new tsss();
c.setHeight(height);
c.setlen(length);
c.setwen(wide);
System.out.println("长方体的长为:"+c.getlength()+" 宽为:"+c.getwidth()+" 高为:"+c.getHeight());
System.out.println("长方体的体积为:"+c.tiji());
}
}