2020.4.19

 
 
package lei;


     


import java.util.Scanner;

public class Rectangle {
    int length;
    int width ;
    int showAll;

    public static void main(String[] args) {
        // TODO Auto-generated method stub
        Rectangle R = new Rectangle();
        Scanner input = new Scanner(System.in);
        System.out.println("请输入长:");
        R.length = input.nextInt();
        System.out.println("请输入宽:");
        R.width = input.nextInt();
        R.showAll();
    }

}
 
  
 
package lei;

public class Rectangle {
     int length;
        int width;
        
        public void getArea() {
            System.out.println(length * width);
        }
        
        public void getPer() {
            System.out.println((length + width) * 2);
        }
        
        public void showAll() {
            System.out.println("长:" + length);
            System.out.println("宽:" + width);
            System.out.print("面积:");
            getArea();
            System.out.print("周长");
            getPer();
        }

    }

猜你喜欢

转载自www.cnblogs.com/yyyyym/p/12731426.html
今日推荐