In class, we discussed an example of how to compute the growth of money over time, with regular annual contributions. Le

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899604
Joined: Mon Aug 02, 2021 8:13 am

In class, we discussed an example of how to compute the growth of money over time, with regular annual contributions. Le

Post by answerhappygod »

In class, we discussed an example of how to compute the growth of money over time, with regular annual contributions. Let’s approach this problem from another angle: given your current financial situation and a retirement goal you have in mind, how much should you contribute each year to achieve that goal? To make this more realistic than our in-class example, we’ll also allow the contribution each year to grow over time. People can often contribute more as they advance in their career and their earnings increase.
Write a program named retirement calculator.py that starts by getting the following user inputs:
• Current age
• Target retirement age
• Current retirement savings, in USD
• Target savings at retirement, in USD
• Annual growth rate, as a percentage (“growth” is just a more general term for the “interest” idea that we covered in class)
• Amount to increase the annual contribution by each year, as a percentage. We’ll assume that this percentage is consistent throughout the person’s entire career. For example, a figure of 2% might mean that the person contributes $1000 the first year, $1020 (2% more than $1000) the second year, $1040.40 (2% more than $1020) the third year, and so on.
Include input validation (using a loop) on all of these to ensure that the values must be non- negative (i.e., 0 or greater). Furthermore, include input validation on the target retirement age to ensure that it cannot be less than the user’s current age, and the target retirement savings to ensure that it cannot be less than the user’s current savings.
Based on those inputs, the program should compute the minimum possible contribution the user can make their first year to meet their goals. Also show a table with the projected growth
Page 3 of 7
COMP 1900 - Summer 2022 Lab 5 Due Wed., July 13, by 2359 CDT
from the user’s current age until retirement, formatted like the examples below. Monetary amounts should be rounded to two decimal places.
Hints:
• Start by assuming the user contributes $0 their first year. This will make every other year’s contribution $0 too, since any percentage of 0 is still 0. But the user might already have enough saved up to meet their goals without contributing anything extra, so this scenario should be considered.
• If the user can’t meet their goals with $0 contributions, increase the first-year contribution to $0.01, run the simulation again, and see if they end up with enough at retirement. If not, increase the first-year contribution to $0.02, and so on. Keep repeating this process until you find that the ending balance meets or exceeds the user’s goal.
• This program should involve at least one nested loop! Depending on the inputs, the program may take a considerable amount of time to find the solution.
Example program run (underlined parts indicate what the user enters)
Your current age: -9
Age must be non-negative, try again: 25
Target retirement age: 20
Retirement age must be at least 25, try again: 40
Current savings (in USD): 400000
Target savings at retirement (in USD): 0
Amount must be at least $400000.00, try again: 750000
Annual growth rate (in percent): 6.5
Amount to increase annual contribution by each year (in percent): 2
Save $0.00 this year and increase it by 2.0% each year until retirement.
In Class We Discussed An Example Of How To Compute The Growth Of Money Over Time With Regular Annual Contributions Le 1
In Class We Discussed An Example Of How To Compute The Growth Of Money Over Time With Regular Annual Contributions Le 1 (58.36 KiB) Viewed 30 times
In Class We Discussed An Example Of How To Compute The Growth Of Money Over Time With Regular Annual Contributions Le 2
In Class We Discussed An Example Of How To Compute The Growth Of Money Over Time With Regular Annual Contributions Le 2 (55.17 KiB) Viewed 30 times
3. (20 points) In class, we discused an example of bow to coenpute the growth of namey over time, with regular annual contributions. Let's approarh this problem from another angles given your current finmcial situation and a retiresnent goal you have in mind, how nrach showd you contribate each gear to achieve that goal? To make this more realistic than our in-class example, we'll also allow the contribution each year to grow oser time. People ean often contribute more as they advance in their career and their earmings increase, Write a program named retirement.calculator-py that starts by getting the following user imputs: - Carrent age - Target retirement age - Current retirement savings, in USD - Target savings at retirement, in USD - Aunual growth rate, as a percentage ("grosth" is just a taote general term for the "interest" idea that we covered in clater) - Amount to increase the anaual contrihution by each year, as a perceatage. We'll assmmiet that this pereentage is consistent thronghout the person's entire eareer. For example, a figure of 2% might mean that the person contribetes $1000 the first year, $1020(2% more than 81000) the second year, $1040.40(2% mose than $1020) the third year, and so on. Include inpet ealidation (using a loop) cil all of these te ensure that the values mist be nonnegative (i.e, 0 or greater). Furthermote, inclube iopert validation on the target retirencent age to ensure that it cannst be less than the user's curreat age, and the target retirement savings to ensure that it cannot be loss than the aser's current savings. Based on those inpats, the program shonild compute the minimun possible contribution the user can make their first year to meet thrir goak. Also show a table with the projected growth Page 3 of 7 COMP 1900 - Summer 2022 Lab 5 Due Wed.. July 13, by 2359 CDT frotn the user's current age until retiretnent. formatted like the examples below. Monetary amotints shoukld be rounded to two decimal places. Hints: - Start by assuming the aser contributes $0 their first year. This will maloe every other year's contribution 50 too, since any percentage of 0 is still 0 . But the nser might already have enough saved up to meet their goals without contrilating anything extra, so this scenarjo should be considered. - If the user can't meet their goals with $0 contributions, increase the first-year contribution to $0.01, run the simulation again, and see if they end up with enough at retirement. If not, increase the first-year contribution to 90.02. and so on. Keep repeating this process until you find that the ending balance meets or exceeds the mer's goal. - This program should involve at least one nested boopl Depending on the inputs, the program may take a considerable amount of time to find the solution. Example program run (underlined parts indicate what the user enters)
- If the user can't meet their goals with $0 coutributions, increase the first-year contriluation to $0.01, run the simulation again, and see if they end up with enomgh at retirement. If not, increase the first-year contribution to $0.02, and so on. Kep repeating this process until you find that the ending balance meets or excecds the nser's goal. - This program shoald involve at least one mested loop? Depending on the inpats, the program may take a considerable amosant of time to find the solution. Example program run (underlined parts indicate what the user enters) Page 4 of 7
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply