(The Rectangle class) Following the example of the Circle class in Section 8.2, design a class named Rectangle to represent a rectangle. The class contains: . Two double data fields named width and height that specify the width and height of the rectangle. The default values are 1 for both width and height. A no-arg constructor that creates a default rectangle . A constructor that creates a rectangle with the specified width and height. a A method named getArea) that returns the area of this rectangle. . A method named getPerimeter) that returns the perimeter. Draw the UML diagram for the class and then implement the class. Write a test program that creates two Rectangle objects-one with width 4 and height 40 and the other with width 3.5 and height 35.9. Display the width, height, area, and perimeter of each rectangle in this order. SAMPLE RUN #0: java Rectangle Standard Output Hide Invisibles The-area-of-a-4.0.x-48.อ-Rectangle-is-168.0 The.perimeter.of a.4.0.x.40.0 Rectangleis 88.0 The area of.a.3.5 x 35.9.Rectangle.is.125.64999999999999 The perimeter.of .a.3.5 x 35.9 Rectangle.is.78.8

Question

(The Rectangle class)

Following the example of the Circle class in Section 8.2,
design a class named Rectangle to represent a rectangle. The class contains:

■ Two double data fields named width and height that specify the width and
height of the rectangle. The default values are 1 for both width and height.
■ A no-arg constructor that creates a default rectangle.
■ A constructor that creates a rectangle with the specified width and height.
■ A method named getArea() that returns the area of this rectangle.
■ A method named getPerimeter() that returns the perimeter.

Draw the UML diagram for the class and then implement the class. Write a test
program that creates two Rectangle objects—one with width 4 and height 40
and the other with width 3.5 and height 35.9. Display the width, height, area,
and perimeter of each rectangle in this order.

(The Rectangle class) Following the example of the Circle class in Section 8.2,
design a class named Rectangle to represent a rectangle. The class contains:
. Two double data fields named width and height that specify the width and
height of the rectangle. The default values are 1 for both width and height.
A no-arg constructor that creates a default rectangle
. A constructor that creates a rectangle with the specified width and height.
a A method named getArea) that returns the area of this rectangle.
. A method named getPerimeter) that returns the perimeter.
Draw the UML diagram for the class and then implement the class. Write a test
program that creates two Rectangle objects-one with width 4 and height 40
and the other with width 3.5 and height 35.9. Display the width, height, area,
and perimeter of each rectangle in this order.
SAMPLE RUN #0: java Rectangle
Standard Output
Hide Invisibles
The-area-of-a-4.0.x-48.อ-Rectangle-is-168.0
The.perimeter.of a.4.0.x.40.0 Rectangleis 88.0
The area of.a.3.5 x 35.9.Rectangle.is.125.64999999999999
The perimeter.of .a.3.5 x 35.9 Rectangle.is.78.8

Image Transcription

(The Rectangle class) Following the example of the Circle class in Section 8.2, design a class named Rectangle to represent a rectangle. The class contains: . Two double data fields named width and height that specify the width and height of the rectangle. The default values are 1 for both width and height. A no-arg constructor that creates a default rectangle . A constructor that creates a rectangle with the specified width and height. a A method named getArea) that returns the area of this rectangle. . A method named getPerimeter) that returns the perimeter. Draw the UML diagram for the class and then implement the class. Write a test program that creates two Rectangle objects-one with width 4 and height 40 and the other with width 3.5 and height 35.9. Display the width, height, area, and perimeter of each rectangle in this order. SAMPLE RUN #0: java Rectangle Standard Output Hide Invisibles The-area-of-a-4.0.x-48.อ-Rectangle-is-168.0 The.perimeter.of a.4.0.x.40.0 Rectangleis 88.0 The area of.a.3.5 x 35.9.Rectangle.is.125.64999999999999 The perimeter.of .a.3.5 x 35.9 Rectangle.is.78.8

Expert Answer

Want to see the step-by-step answer?

See Answer

Check out a sample Q&A here.

Want to see this answer and more?

Experts are waiting 24/7 to provide step-by-step solutions in as fast as 30 minutes!*

See Answer
*Response times vary by subject and question complexity. Median response time is 34 minutes and may be longer for new subjects.

Related Computer Science Q&A

Find answers to questions asked by student like you

Q: You are not required to execute the queries. However, your syntax must by accurate.You must give at ...

A: Answer for 11: SELECT MIN(MEM_BALANCE) AS MINIMUM_BALANCE, MAX(MEM_BALANCE) AS MAXIMUM_BALANCE, AVG(...

Q: I am struggling on storing numbers from the getChoice () function into an array and pulling it back ...

A: Click to see the answer

Q: 5-13) Find the largest n such that n cubed is less than a positive integer entered by the user. Use ...

A: The heart of the algorithm lies in finding such a number whose cube is less than the given number he...

Q: I need help with understanding how to do the SQL code for the following question (attached is the CS...

A: As the table name is not shown in the picture, we are assuming the table name as Product. There are ...

Q: Create a new file in c++ and save it as lab11_XYZ.cpp (replace XYZ with your initials). Create ANOTH...

A: Program Instructions:In the header file, create a temporary variable temp of the data type of each v...

Q: What form of storage doses a password manger store encrypted passwords? Is it local, web sites, clod...

A: Passwords managers allows one to generate strong and unique passwords and store them in one safe pla...

Q: Write a function is_mirror(s) that takes as input a string s and returns True if s is a mirrored str...

A: The algorithm for the program would be as follows:Find the length of the program if it is even lengt...

Q: Used Java 4.23 (Financial application: payroll) Write a program that reads the following information...

A: The program would have the following 4 sections:The declaration and initialization of the variables ...

Q: Visual Basic. Given two variables, isEmpty of type boolean, indicating whether a class roster is emp...

A: We have to check two conditions:-1) class roster is not empty 2) The class has more than two credits...