Reference no: EM132356268
Practice
Write a quick calculator that prompts for the rate of return on an investment and calculates how many years it will take to double your investment.
The formula is years = 72 / r, where ris the stated rate of return.
Example Output
What is the rate of return?
0
Sorry. That's not a valid input.
What is the rate of return?
ABC
Sorry.
That's not a valid input.
What is the rate of return?
4
It will take 18 years to double your initial investment.
Constraints
- Don't allow the user to enter 0.
- Don't allow non-numeric values.
- Use a loop to trap bad input, so you can ensure that the user enters valid values.