public class Demo1 {
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);
System.out.println("面积是");
getArea();
System.out.println("周长是");
getPer();
}
}
import java.util.*;
public class Demo1 {
public static void main(String[] args) {
Rectangle p1 = new Rectangle();
Scanner input = new Scanner(System.in);
System.out.println("请输入长");
p1.length = input.nextInt();
System.out.print("请输入宽");
p1.width = input.nextInt();
p1.showAll();
}
}