This needs to have a very similar set up to the examples in thequestion(Chart, inputs, etc...)(Also, please try to use while orfor loops for the solution thanks!)
In short, you need to be able to get the user age, targetretirement age, current savings, planned retirement savings,interest in percent, and percentage to boost your contribution by.The program should be able to have contribution = 0 and add .01 ina loop until it is equal or more than the retirement savings. I canfigure out how to make everything work other than contributionpart.
3. (20 points) In class, we discussed an example of how tocompute the growth of money over time, with regular annualcontributions. Let’s approach this problem from another angle:given your current financial situation and a retirement goal youhave in mind, how much should you contribute each year to achievethat 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 careerand their earnings increase. Write a program named retirementcalculator.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 theannual contribution by each year, as a percentage. We’ll assumethat this percentage is consistent throughout the person’s entirecareer. For example, a figure of 2% might mean that the personcontributes $1000 the first year, $1020 (2% more than $1000) thesecond year, $1040.40 (2% more than $1020) the third year, and soon. Include input validation (using a loop) on all of these toensure that the values must be non- negative (i.e., 0 or greater).Furthermore, include input validation on the target retirement ageto ensure that it cannot be less than the user’s current age, andthe target retirement savings to ensure that it cannot be less thanthe user’s current savings. Based on those inputs, the programshould compute the minimum possible contribution the user can maketheir first year to meet their goals. Also show a table with theprojected growth Page 3 of 7 COMP 1900 - Summer 2022 Lab 5 DueWed., July 13, by 2359 CDT from the user’s current age untilretirement, formatted like the examples below. Monetary amountsshould be rounded to two decimal places. Hints: • Start by assumingthe user contributes $0 their first year. This will make everyother year’s contribution $0 too, since any percentage of 0 isstill 0. But the user might already have enough saved up to meettheir goals without contributing anything extra, so this scenarioshould be considered. • If the user can’t meet their goals with $0contributions, increase the first-year contribution to $0.01, runthe simulation again, and see if they end up with enough atretirement. If not, increase the first-year contribution to $0.02,and so on. Keep repeating this process until you find that theending balance meets or exceeds the user’s goal. • This programshould involve at least one nested loop! Depending on the inputs,the program may take a considerable amount of time to find thesolution. Example program run (underlined parts indicate what theuser enters) Your current age: -9 Age must be non-negative, tryagain: 25 Target retirement age: 20 Retirement age must be at least25, try again: 40 Current savings (in USD): 400000 Target savingsat retirement (in USD): 0 Amount must be at least $400000.00, tryagain: 750000 Annual growth rate (in percent): 6.5 Amount toincrease annual contribution by each year (in percent): 2 Save$0.00 this year and increase it by 2.0% each year untilretirement.
Projected growth: ----------------- Age Year Start GrowthContribution Year End 25 $ 400000.00 $ 26000.00 $ 0.00 $ 426000.0026 $ 426000.00 $ 27690.00 $ 0.00 $ 453690.00 27 $ 453690.00 $29489.85 $ 0.00 $ 483179.85 28 $ 483179.85 $ 31406.69 $ 0.00 $514586.54 29 $ 514586.54 $ 33448.13 $ 0.00 $ 548034.67 30 $548034.67 $ 35622.25 $ 0.00 $ 583656.92 31 $ 583656.92 $ 37937.70 $0.00 $ 621594.62 32 $ 621594.62 $ 40403.65 $ 0.00 $ 661998.27 33 $661998.27 $ 43029.89 $ 0.00 $ 705028.16 34 $ 705028.16 $ 45826.83 $0.00 $ 750854.99 35 $ 750854.99 $ 48805.57 $ 0.00 $ 799660.56 Page4 of 7 COMP 1900 - Summer 2022 Lab 5 Due Wed., July 13, by 2359 CDT36 $ 799660.56 $ 51977.94 $ 0.00 $ 851638.50 37 $ 851638.50 $55356.50 $ 0.00 $ 906995.00 38 $ 906995.00 $ 58954.67 $ 0.00 $965949.67 39 $ 965949.67 $ 62786.73 $ 0.00 $ 1028736.40 40 $1028736.40 $ 66867.87 $ 0.00 $ 1095604.27
Example program run (underlined parts indicate what the userenters) Your current age: 25 Target retirement age: 60 Currentbalance (in USD): 0 Target balance at retirement (in USD): 1500000Annual growth rate (in percent): 7 Amount to increase annualcontribution by each year (in percent): 2 Save $7992.29 this yearand increase it by 2.0% each year until retirement. Projectedgrowth: ----------------- Age Year Start Growth Contribution YearEnd 25 $ 0.00 $ 0.00 $ 7992.29 $ 7992.29 26 $ 7992.29 $ 559.46 $8152.14 $ 16703.89 27 $ 16703.89 $ 1169.27 $ 8315.18 $ 26188.34 28$ 26188.34 $ 1833.18 $ 8481.48 $ 36503.00 29 $ 36503.00 $ 2555.21 $8651.11 $ 47709.32 30 $ 47709.32 $ 3339.65 $ 8824.13 $ 59873.11 31$ 59873.11 $ 4191.12 $ 9000.62 $ 73064.85 32 $ 73064.85 $ 5114.54 $9180.63 $ 87360.01 33 $ 87360.01 $ 6115.20 $ 9364.24 $ 102839.46 34$ 102839.46 $ 7198.76 $ 9551.53 $ 119589.74 35 $ 119589.74 $8371.28 $ 9742.56 $ 137703.58 36 $ 137703.58 $ 9639.25 $ 9937.41 $157280.24 37 $ 157280.24 $ 11009.62 $ 10136.16 $ 178426.02 38 $178426.02 $ 12489.82 $ 10338.88 $ 201254.72 39 $ 201254.72 $14087.83 $ 10545.66 $ 225888.20 40 $ 225888.20 $ 15812.17 $10756.57 $ 252456.95 41 $ 252456.95 $ 17671.99 $ 10971.70 $281100.63 42 $ 281100.63 $ 19677.04 $ 11191.14 $ 311968.81 43 $311968.81 $ 21837.82 $ 11414.96 $ 345221.59 44 $ 345221.59 $24165.51 $ 11643.26 $ 381030.36 45 $ 381030.36 $ 26672.13 $11876.12 $ 419578.61 46 $ 419578.61 $ 29370.50 $ 12113.64 $461062.75 47 $ 461062.75 $ 32274.39 $ 12355.92 $ 505693.06 Page 5of 7 COMP 1900 - Summer 2022 Lab 5 Due Wed., July 13, by 2359 CDT48 $ 505693.06 $ 35398.51 $ 12603.04 $ 553694.61 49 $ 553694.61 $38758.62 $ 12855.10 $ 605308.33 50 $ 605308.33 $ 42371.58 $13112.20 $ 660792.12 51 $ 660792.12 $ 46255.45 $ 13374.44 $720422.01 52 $ 720422.01 $ 50429.54 $ 13641.93 $ 784493.48 53 $784493.48 $ 54914.54 $ 13914.77 $ 853322.79 54 $ 853322.79 $59732.60 $ 14193.07 $ 927248.46 55 $ 927248.46 $ 64907.39 $14476.93 $ 1006632.77 56 $ 1006632.77 $ 70464.29 $ 14766.47 $1091863.53 57 $ 1091863.53 $ 76430.45 $ 15061.79 $ 1183355.78 58 $1183355.78 $ 82834.90 $ 15363.03 $ 1281553.71 59 $ 1281553.71 $89708.76 $ 15670.29 $ 1386932.76 60 $ 1386932.76 $ 97085.29 $15983.70 $ 1500001.75
This needs to have a very similar set up to the examples in the question(Chart, inputs, etc...)(Also, please try to use
-
answerhappygod
- Site Admin
- Posts: 899604
- Joined: Mon Aug 02, 2021 8:13 am
This needs to have a very similar set up to the examples in the question(Chart, inputs, etc...)(Also, please try to use
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!