第七周作业

1.package finish;
public class csy {
    int length;
    int width;
    public static void main(String[] args){}
    public void getArea() {
    int a=width*length; 
    System.out.println("面积"+a);
    }
    public void getPer() {
    int b=(width+length)*2; 
    System.out.println("周长:"+b);
    }
    public void showAll() {
    System.out.println("宽:"+width);
    System.out.println("长"+length);
    getPer();
    getArea();

    }
    }
2.package finish;
import java.util.Scanner;
public class csy {
    public static void main(String[] args) {
        // TODO Auto-generated method stub
        Rectangle r1 = new Rectangle();
        Scanner input = new Scanner(System.in);
        System.out.print("请输入长度:");
        r1.length = input.nextInt();
        System.out.print("请输入宽度:");
        r1.width = input.nextInt();
        r1.showAll();
    }
}

 


 

posted @ 2020-04-22 12:30  csy521  阅读(101)  评论(0编辑  收藏  举报