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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started