Question: Note: Please provide source code for java only and the sample run (output) should be the same according to the question displayed below. Exercise#1 Design
Note: Please provide source code for java only and the sample run (output) should be the same according to the question displayed below.
Exercise#1 Design and implement the class Rectangle to represent a rectangle object. The class defines the following attributes (variables) and methods Two class variables of type double named height and width to represent the height and width of the rectangle. Set their default values to 1 in the default constructor. 2. A non-argument constructor method to create a default rectangle 3. Another constructor method to create a rectangle with user-specified height and width 4. Method getArea) that returns the area 5. Method getPerimeter ()that returns the perimeter 6. Method getHeight that returns the height 7. Method getwidth () that returns the width Now design and implement a test program to create two rectangle objects: one with default height and width, and the second is 5 units high and 6 units wide. Next, test the class methods on each object to print the information as shown below Sample run: First object: Height: Width: Area: Perimeter 4 units 1 unit 1 unit 1 unit Second object: Height: Width: Area: Perimeter 22 unit 5 unit 6 unit 30 units
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
