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
Hint: the area of a rectangle is the product of length and width. The perimeter of a rectangle is width * 2 + length * 2.
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
Get step-by-step solutions from verified subject matter experts
