python计算长⽅形的周长和⾯积_计算矩形的周长和⾯积我需要能够将矩形的长度和宽度输⼊到控制台并计算其周长和⾯积。除了接受我的输⼊以进⾏计算外,我还有其他⼯作。我知道我很接近,但似乎⽆法弄清楚。在此先感谢您的帮助。请记住,我是⼀个很好的新⼿,所以你的答案⼀开始可能对我没有意义。我⽆法得到它来计算我输⼊到控制台的值。
package it325_lab1;
public class Rectangle {
private static double length;电磁炉专用锅
private static double width;
public Rectangle() {
匹配函数length=0.0;
width=0.0;
}
public Rectangle(double l, double w) {
length = l;
width = w;
}
public double FindArea() {
return length*width;
}
public double FindPerim() {
return length*2 + width*2;
}
}
package it325_lab1;
import java.util.Scanner;
结尾摘抄public class TestRectangle {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner scanL = new Scanner (System.in);
System.out.print("Plea enter the length of the rectangle: ");
double L = Double();
Scanner scanW = new Scanner (System.in);
System.out.print("Plea enter the length of the rectangle: ");
double W = Double();
//int W = Int();
double RectangleArea;
儿童拼音Rectangle unitRectangle = new Rectangle();
确凿的意思传菜RectangleArea = unitRectangle.FindArea();
System.out.println("The area of a unit rectangle is " + RectangleArea);
double RectanglePermiter;
Rectangle perimRectangle = new Rectangle();
正规邮件格式范文>八月瓜RectanglePermiter = perimRectangle.FindPerim();
System.out.println("The permimiter of the unit rectangle is " + RectanglePermiter); }
}