Question: implement the InvestmentCalculator with a method called calculate _ future _ value that takes three parameters: principal _ amount, annual _ interest _ rate, and

implement the "InvestmentCalculator" with a method called calculate_future_value that
takes three parameters: principal_amount, annual_interest_rate, and years. The
calculate_future_value method should calculate the future value of an investment using
the formula: future_value = principal_amount *(1+ annual_interest_rate)** years.
Use try-catch blocks to handle exceptions where the user inputs a negative interest rate
or an invalid (non-numeric) value for any of the parameters.
If a negative interest rate is inputted, raise an ArgumentError with a message explaining
that the interest rate cannot be negative.
Catch the ArgumentError and any other generic exception, printing a custom message to
the console for each case.
Wrap the user input section in a while loop that continues prompting the user until valid
inputs are received, and the future value has been successfully calculated and displayed.
Example result
Valid input

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 Programming Questions!