题目描述:
编写程序,显示宽为4.5,高为7.9的矩形的面积和周长。
代码:
public class Rectangle {
public static void main(String[] args){
final double width=4.5,height=7.9;
double area = width*height;
double girth = (width+height)*2;
System.out.println("The girth of the rectangle is: "+girth);
System.out.println("The area of the rectangle is: "+area);
}
}
运行示例: