Question: Create a class called Rectangle with two instance variables width and height that are of type double. Provide a method called calculatePerimeter that calculates the

Create a class called Rectangle with two instance variables width and height that are of type double. Provide a method called calculatePerimeter that calculates the perimeter of the rectangle, and provide a method called calculateArea that calculates the area of the rectangle. Both methods should return doubles. The class should also have set and get methods for setting and getting the width and height instance variables. The set methods should verify that the length and width specified should be within the range of 0.0 and 20.0. Ensure you code is commented well, especially the set methods explaining the input restrictions and what happens if the restrictions are not met.

Write a program to test the Rectangle class.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!