第七周作业
package Wxte; public class Rectangle { double length; double 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); getArea(); getPer(); } }
package Wxte; import java.util.Scanner; public class Mask { public static void main(String[] args) { // TODO Auto-generated method stub Rectangle b = new Rectangle(); Scanner input = new Scanner(System.in); System.out.print("输入长:"); b.length = input.nextInt(); System.out.print("输入宽:"); b.width = input.nextInt(); b.showAll(); } }