第8次作业

package jiecheng;

import java.util.Scanner;


public class zuoye8 {

    public static void main(String[] args) {
        Scanner reader=new Scanner(System.in);
        zy h=new zy();
        System.out.println("请输入长与宽");
h.seta1(reader.nextInt(),reader.nextInt());
System.out.println("周长为:"+h.setzhouchang());
 yz i=new yz();
System.out.println(" 请输入正方形的边长");
i.setc1(reader.nextInt());
System.out.println("正方形的面积为:"+i.setarea());
System.out.println("正方形的周长为:"+i.setzhouchang());
    }

}
class zy{

int a1;

int b1;
int zhouchang;
 int  setzhouchang() {
    zhouchang=a1*2+b1*2;
    return zhouchang;
}

void seta1(int x,int y){
    this.a1=x;
    this.b1=y;
}
}
class yz extends zy{
    int c1;
    int area;
    void setc1(int x) {
        this.c1=x;
    }
    int setzhouchang() {
        zhouchang=c1*4;
        return zhouchang;
    }
    int setarea() {
        area=c1*c1;
        return area;
    }
    
}

第8次作业_第1张图片

 

你可能感兴趣的:(第8次作业)