Question: Define class Rectangle, a rectangle has two attributes: width and length. For simplicity, you can assume that both width and length are integers. Write constructors

Define class Rectangle, a rectangle has two attributes: width and length. For simplicity, you can assume that both width and length are integers. Write constructors (one default, and another takes two integers parameters), getters (getWidth, getLength, getArea, getPerimeter), setters (setWidth, setLength), toString, and equals methods. Test these methods in your RectangleClient class.

Hint: the area of a rectangle is the product of length and width. The perimeter of a rectangle is width * 2 + length * 2.

2. Page 418, Problem 72 (5e)

Write a class encapsulating the concept of an investment, assuming the investment has the following attributes: the amount of the investment and the interest rate at which the investment will be compounded. Include a constructor, the accessors and mutators toString and equals. Also include a method returning the future value of the investment depending on how many years we hold it before selling it, which can be calculated using the following formula:

Future value = investment ( 1 + interest rate)numberOfYears

We will assume that the interest rate is compounded annually. Write a client class to test all the methods in your 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!