第七周作业
package test;
import java.util.Random;
import java.util.Scanner;
public class hhh {
public static void main(String[] args) {
// TODO Auto-generated method stub
Rectangle r=new Rectangle();
r.length=3.6;
r.width=1.2;
r.getPer();
r.getArea();
r.showAll();
}
}
package test;
import java.util.Scanner;
public class Rectangle {
double length;
double width;
public void getArea() {
double area=length*width;
System.out.println("面积为"+area);
}
public void getPer() {
double per= 2*(length+width);
System.out.println("周长为"+per);
}
public void showAll() {
System.out.println("长为"+length);
System.out.println("宽为"+width);
System.out.println("面积为"+length*width);
System.out.println("周长为"+(length+width));
}
}


浙公网安备 33010602011771号