Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access with AI-Powered 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

Students also viewed these Databases questions