<pre name= "code" class= "java" >/* * Copyright (c) 2015, Computer College of Yantai University * All rights reserved. * File name: Test.java * Author: Wang Yuanyang * Completion date: October 20, 2015 * Version number: v1.0 * Problem Description: Construct a rectangular class and assign long and wide initial values to 1, and finally output long, wide, and face
Product. * * public class Rectangle {/** * @param args/public static void main (string[] args) {//TODO Auto-generat
Ed method stub Rectangle1 Rectangle1 = new Rectangle1 (4, 40); System.out.println ("The area of the rectangle of width" + rectangle1.width + "and height" + rectangle1.height + "I
S "+ Rectangle1.getarea ());
Rectangle1 rectangle2 = new Rectangle1 (3.5, 39.5); System.out.println ("The area of the rectangle of width" + rectangle2.width + "and height" + rectangle2.height + "I
S "+ Rectangle2.getarea ());
} class Rectangle1 {double width;
Double height;
Rectangle1 () {width = 1.0;
Height = 1.0;
} Rectangle1 (double newwidth, double newheight) {width = newwidth;
Height = newheight; } DOUBLe Getarea () {return width * height; }
}