Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Instructions: For this assignment, you will write the first part of a program that allows a customer to plan for retirement . Note: This program

Instructions:

For this assignment, you will write the first part of a program that allows a customer to plan for retirement. Note: This program has no user input

Write a "pure" Python function named 'calc_final_balance' that calculates the final balance in a retirement account after annual savings accrue for and earn interest for a number of years. This is a simulation problem similar to the Credit Card sample program, except it is to be written as a function definition (which means, among other things, that it uses parameters instead of user input). Here is the specification:

  • The function requires 3 parameters: the starting age for saving, the amount saved each year, and the percentage interest rate. This function may assume that the values have been previously validated -- no input validation is needed in this function.
  • Saving is assumed to stop at age 70.
  • The function uses a loop to perform a simulation of retirement savings. The loop iterates one time for each year that savings occur. Each year, the account balance is increased by the amount saved each year, and then -- after this increase -- the account earns one year's interest.
  • The function should return the final balance at age 70.

TEST the 'calcFinalBalance' function by adding statements in the 'main program' to print out the final balance for several test cases and confirm that it is correct. For example, these statements: print('$' + format(calc_final_balance( 30, 3000, 6 ), '.2f')) print('$' + format(calc_final_balance( 20, 2000, 5.5 ), '.2f')) should write on the web page the results $492143.05 and $519518.88. Choose test cases that check the function thoroughly, and document your testing in comments.

Here is a simple test case you can more easily trace by hand: calc_final_balance( 65, 2000, 10 )should return the value 13431.22.

Documentation & Style Specifications

  • Include a main comment block at the beginning of the file listing that has your name, date, class and section number, and a brief description (one or two lines) of the project.
  • Include a comment block before the function header to describe a) what the function does and b) how the function's parameters are used. Follow the style you see in the posted examples, and in particular the cube_root.py sample program, which demonstrates the difference between the comment block at the very beginning of a code file and the comment block located before a function header.
  • Include blank lines where appropriate to make the program easier to read.
  • Use descriptive variable names.
  • Include comments at the end of your program that describe at least 3 test cases, the results you saw, and why you believe those results are correct, as you did for previous assignments.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Machine Learning And Knowledge Discovery In Databases European Conference Ecml Pkdd 2015 Porto Portugal September 7 11 2015 Proceedings Part 3 Lnai 9286

Authors: Albert Bifet ,Michael May ,Bianca Zadrozny ,Ricard Gavalda ,Dino Pedreschi ,Francesco Bonchi ,Jaime Cardoso ,Myra Spiliopoulou

1st Edition

ISBN: 3319234609, 978-3319234601

More Books

Students also viewed these Databases questions

Question

1. Are my sources credible?

Answered: 1 week ago

Question

3. Are my sources accurate?

Answered: 1 week ago

Question

1. Is it a topic you are interested in and know something about?

Answered: 1 week ago