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:
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
code:
'''function to calculate total savings for given period'''
def
calc_final_balance(strart_age,savings_each,percentage_int):
#variable to store total savings
sum_of_money = 0
#loop from start age to 70
for i in range(strart_age,71):
#for last year dont add or calculate interest because it stops at
70
if i==70:
#pass does nothing
pass
else:
#add savings each year then add interest tot it
sum_of_money = sum_of_money + savings_each
sum_of_money = sum_of_money*(1+(percentage_int/100))
return sum_of_money
print('$' + format(calc_final_balance( 30, 3000, 6 ), '.2f'))
print('$' + format(calc_final_balance( 20, 2000, 5.5 ),
'.2f'))
print('$' + format(calc_final_balance( 65,2000,10 ), '.2f'))
output:
explanation:
first we take sum_of_money as 0.
in for loop we loop through start age to 70.
if condition:
when someone enters age 70, for that year we dont need to add savings and interest because it stops at 70.
else:
add the savings to each year and add interest also.
return and display the total savings.
Note: if u have any doubt, let me know.
Instructions: For this assignment, you will write the first part of a program that allows a...
-----------Python program------------------- Instructions: For this assignment, you will write complete a program that allows a customer to plan for retirement. Part 2: Generate a Retirement Planning Table: It's hard to decide how much you need to save for retirement. To help your customer visualize how long her nest egg will last, write a program that allows the user to generate a retirement planning table showing the number of months the savings will last for various combinations of starting account balance...
Write a C++ program that calculates the discount of the original price of an item and displays the new price, and the total amount of savings. This program should have a separate header (discount.h), implementation (discount.cpp) and application files (main.cpp). The program must also have user input: the user must be prompted to enter data (the original price, and the percent off as a percentage). There must also be a validation, for example: Output: “Enter the original price of the...
Assignment Overview In Part 1 of this assignment, you will write a main program and several classes to create and print a small database of baseball player data. The assignment has been split into two parts to encourage you to code your program in an incremental fashion, a technique that will be increasingly important as the semester goes on. Purpose This assignment reviews object-oriented programming concepts such as classes, methods, constructors, accessor methods, and access modifiers. It makes use of...
Write in C++ using emacs. Write a program that calculates the ending balance of several savings accounts. The program reads information about different customers’ accounts from an input file, “accounts.txt”. Each row in the file contains account information for one customer. This includes: the account number, account type (premium, choice, or basic account), starting balance, total amount deposited, and total amount withdrawn. Your program should: - open the file and check for successful open, - then calculate the ending balance...
Purpose: Demonstrate the ability to create and manipulate classes, data members, and member functions. This assignment also aims at creating a C++ project to handle multiple files (one header file and two .cpp files) at the same time. Remember to follow documentation and variable name guidelines. Create a C++ project to implement a simplified banking system. Your bank is small, so it can have a maximum of 100 accounts. Use an array of pointers to objects for this. However, your...
You will write a C program, q1 sequence.c, that computes the value of the nth term in any recursive sequence with the following structure: an = c1 · an−1 + c2 · an−2 a0 > 0 a1 > 0 c1 6= 0 c2 6= 0 Your C program will take 5 integer arguments on the command line: n, a0, a1, c1 and c2. n must be an integer greater than or equal to 0. If more or fewer arguments are...
1. The first small program realizes the following functions: (1) The program allows input of ID (3-digit integer representation), month (1-12), revenue and record these information in file1 (2) If the ID entered by the user and the income of the corresponding month already exist in file1, remind: the income information has been entered, please do not repeat the entry 2. The second small program realizes the following functions: (1) Calculate the tax payable for each ID in file1 in...
You will create a new project. Type in the following program and run it to produce the output for the program. Good practice in writing a program in any language, including Python, is to add comments for each line and state clearly what is the program input and output. Your program must include comments, so a reader will know exactly what you are trying to do in each line of code and allow for easy maintenance. Beginning a line with...
/************************************************************************************ * Program: PRG/420 Week 5 * Purpose: Week 5 Coding Assignment * Programmer: TYPE YOUR NAME HERE * Class: PRG/420 * Creation Date: TYPE TODAY'S DATE HERE ************************************************************************************* * Program Summary: * This program converts a given date to a string. * The code includes exception handling for a ParseException. ************************************************************************************/ package prg420week5_codingassignment; import java.util.*; // wildcard to import all the util. classes import java.text.*; // wildcard to import all the text classes public class PRG420Week5_CodingAssignment { public static...
Python assignment: Write a program that asks for the user's age. Based on their response print "You can vote" (18 years old or older) or "You can't vote" and also whether or not he/she is a senior citizen (over 64). If senior citizen print "You're a Senior Citizen...you deserve two votes"! Use the Idle editor and don't forget the .py extension. Good luck. Your python program will be graded on the following: Execution of the program gives the correct...