Question
Write an application that calculates the amount of money earned on an investment. Prompt the user to enter an investment amount, the number of years
Write an application that calculates the amount of money earned on an investment. Prompt the user to enter an investment amount, the number of years for the investment, and the interest rate. Display an error message if the user enters 0 for any of these values; otherwise, display the total amount (balance) for each year of the investment. Save the file as Investment.java.
Java Program
Specific instructions:
- Program must use 4 methods to accomplish the following:
- Prompt for and return the investment amount
- Prompt for and return the number of years
- Prompt for and return the interest rate
- Display the calculations
Your output must resemble the sample below. Notice the formatting of the dollar amounts. You need to display 2 decimal places for all amounts, even for those with whole dollar amounts.
C:WINDOWS\system32cmd.exe Enter investment amount: 100 Enter number of years 10 Enter interest rate (as a decimal) .05 Your Investment at 5.0% is : After year 1 After year 2 After year 3 After year 4 After year 5 After year 6 After year 7 After year 8 105.00 110.25 115.76 121.55 127.63 134.01 140.71 147.75 155.13 162.89 after year io 3162.39 After year 10D Enter investment amount 0 Invalid investment amount please reenter Enter investment amount 1000 Enter number of years: 0 Years must be a positive whole number-please reenter Enter number of years 3 Enter interest rate as a decimal): 5 Interest rate nust be a positive decimal value please reenter Enter interest rate Kas a decimal: .05 our investment at 5.0% is: After year 1 After year 2 After year 3 1050.00 1102.50 $1157.62
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started