1 import java.util.*; 2 public class T6 { 3 4 public static void main(String[] args) { 5 // TODO Auto-generated method stub 6 7 Rectancle A; 8 A = new Rectancle(); 9 10 System.out.print("请输入矩形的宽和高"); 11 Scanner in = new Scanner(System.in); 12 A.height = in.nextDouble(); 13 A.width = in.nextDouble(); 14 15 System.out.println("矩形的面积为"+A.Carea(A.height,A.width)); 16 System.out.println("矩形的周长为"+A.per(A.height,A.width)); 17 18 } 19 20 } 21 22 class Rectancle{ 23 double height; 24 double width; 25 double area; 26 double perimeter; 27 28 double Carea(double x,double y) { 29 return x*y; 30 } 31 double per(double x,double y) { 32 return 2*(x+y); 33 } 34 35 }