Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Create a class called Rectangle containing the following: Two instance variables, An instance variable of type double used to hold the rectangles width. An instance

Create a class called Rectangle containing the following:

Two instance variables,

An instance variable of type double used to hold the rectangles width.

An instance variable of type double used to hold the rectangles height.

Provide a constructor with two parameters used to initializes each instance variable. The constructor should verify that the specified width and height values are greater than 0.0 and less than or equal to 20.0. If they are not, indicate an exception has occurred.

Provide get methods that return the values of each instance variables.

Provide set methods that set the instance variables to new values. The methods should also verify that the specified width and height values are greater than 0.0 and less than or equal to 20.0. If they are not, indicate an exception has occurred.

Provide a method called calculatePerimeter that calculates the perimeter of the rectangle and return that value as a double.

Provide a method called calculateArea that calculates the area of the rectangle and returns that value as a double.

Create a second class called RectangleTest that contains the main method, and thoroughly tests the Rectangle classs methods. This test class does not need to ask users for input. Just create the needed Rectangle objects to ensure that you test the Rectangle classs methods well.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Conceptual Database Design An Entity Relationship Approach

Authors: Carol Batini, Stefano Ceri, Shamkant B. Navathe

1st Edition

0805302441, 978-0805302448

More Books

Students also viewed these Databases questions

Question

why is equity a non-current liability?

Answered: 1 week ago

Question

Describe effectiveness of reading at night?

Answered: 1 week ago

Question

find all matrices A (a) A = 13 (b) A + A = 213

Answered: 1 week ago

Question

What is the relationship between humans?

Answered: 1 week ago

Question

What is the orientation toward time?

Answered: 1 week ago