Question: Exercise 3 - 3 Enhance the Future Value program In this exercise, you ll enhance the Future Value program so the console display looks something

Exercise 3-3 Enhance the Future Value program
In this exercise, youll enhance the Future Value program so the console display looks something like this:
Welcome to the Future Value Calculator
Enter monthly investment: 0
Entry must be greater than 0. Please try again.
Enter monthly investment: 100
Enter yearly interest rate: 16
Entry must be greater than 0 and less than or equal to 15.
Please try again.
Enter yearly interest rate: 12
Enter number of years: 100
Entry must be greater than 0 and less than or equal to 50.
Please try again.
Enter number of years: 10
Year =1 Future Value =1280.93
Year =2 Future Value =2724.32
Year =3 Future Value =4350.76
Year =4 Future Value =6183.48
Year =5 Future Value =8248.64
Year =6 Future Value =10575.7
Year =7 Future Value =13197.9
Year =8 Future Value =16152.66
Year =9 Future Value =19482.15
Year =10 Future Value =23233.91
Continue (y/n)? n
In IDLE, open the future_value.py file thats in this folder: murach/python/exercises/ch03
Test the program but remember that it doesnt do any validation so enter valid numbers.
Add data validation for the monthly investment entry. Use a while loop to check the validity of the entry and keep looping until the entry is valid. To be valid, the investment amount must be greater than zero. If it isnt, an error message like the first one shown above should be displayed.
Use the same technique to add data validation for the interest rate and years. The interest rate must be greater than zero and less than or equal to 15. And the years must be greater than zero and less than or equal to 50. For each invalid entry, display an appropriate error message. When youre finished, youll have three while loops and a for loop nested within an outer while loop.
Modify the statements in the for loop that calculates the future value so one line is displayed for each year that shows the year number and future value, as shown above. To do that, you need to work with the integer thats returned by the range() function.
When you completed modifications shown above, then enhance your program so the console will look something like this:
Welcome to the Future Value Calculator
Enter monthly investment: 0
Entry must be greater than 0. Please try again.
Enter monthly investment: 100
Enter yearly interest rate: 16
Entry must be greater than 0 and less than or equal to 15.
Please try again.
Enter yearly interest rate: 12
Enter number of years: 100
Entry must be greater than 0 and less than or equal to 50.
Please try again.
Enter number of years: 10
Year 1:
Future Value:1280.93
Total Contributions:1200.0
Total Interest Earned: 80.93
Year 2:
Future Value:2724.32
Total Contributions:2400.0
Total Interest Earned: 324.32
Year 3:
Future Value:4350.76
Total Contributions:3600.0
Total Interest Earned: 750.76
Year 4:
Future Value:6183.48
Total Contributions:4800.0
Total Interest Earned: 1383.48
Year 5:
Future Value:8248.64
Total Contributions:6000.0
Total Interest Earned: 2248.64
Year 6:
Future Value:10575.7
Total Contributions:7200.0
Total Interest Earned: 3375.7
Year 7:
Future Value:13197.9
Total Contributions:8400.0
Total Interest Earned: 4797.9
Year 8:
Future Value:16152.66
Total Contributions:9600.0
Total Interest Earned: 6552.66
Year 9:
Future Value:19482.15
Total Contributions:10800.0
Total Interest Earned: 8682.15
Year 10:
Future Value:23233.91
Total Contributions:12000.0
Total Interest Earned: 11233.91
Would you like to calculate another future value (y/n)? n
Thank you for using the Future Value Calculator. Goodbye!

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!