In: Computer Science
Python problem:
An insurance salesperson knows the following about a client:
The insurance agent wants to know the following:
The formula to calculate the balance of the IRA is:
B = (((1 + r)n - 1) / r) * A
where:
The formula to calculate the Required Minimum Distribution is:
RMD = B / DP
where:
Assume the following:
Instructions
Algorithm
Set required minimum distribution age equal to 70
Set expected interest rate equal to 0.05
Set distribution period equal to 27.4
set current year to 2020
Get user input for birth year
Get user input for the age the user would like to retire
Get user input annual contribution to IRA
Add birth year to retirement age and save as retirement year
Subtract current year from retirement year and save as years until retirement
Add birth year to the required minimum distribution age and save as year of required minimum distribution 
Subtract current year from year of required minimum distribution and save as years until required minimum distribution
To calculate the balance of the IRA for the user's retirement year do the following formula:    
    First find the sum of one plus expected interest rate. Then raise the total to the power of years until retirement.  
    Subtract this total by one
    Then divide your new total by expected interest rate
    last multiply your final number by annual contribution to IRA
Save this number from the formula above to balance at retirement age
To calculate the balance of the IRA for the users required minimum distribution age do following formula:
    first find the sum of one plus expected interest rate. Then raise the total to the power of the required minimum distribution age. 
    Subtract this total by one. 
    then divide your new total by expected interest rate
    last multiply your final number by annual contribution to IRA
Save this number from the formula above to balance at required minimum distribution age
Now to calculate the required minimum distribution that must be taken out.  
Complete the following formula 
    balance at required minimum distribution age divided by distribution period
Save this total from the formula above as required minimum distribution
display current year
display birth year
display retirement age
display annual contribution to IRA
display years until retirement
display years until required minimum distribution
display balance at retirement age
display balance at required minimum distribution age
display required minimum distribution
min_distribution_age = 70 # required minimum distribution age
interest_rate = 0.05 # expected interest rate
distribution_period = 27.4 # distribution period
current_year = 2020 # current year
birth_year = int(input("Enter birth year"))
retirment_age = int(input("Age of retirement"))
IRA_annual = float(input("Annual IRA contribution"))
retirment_year = birth_year + retirment_age # retirement year
year_until_retire = retirment_year - current_year # years until retirement
year_req_min_dist = birth_year + min_distribution_age # year of required minimum distribution
year_until_min_dist = year_req_min_dist - birth_year # years until required minimum distribution
# calculate balance at retirement age
balance_retirement_age = ((((1+interest_rate)**year_until_retire) -1) / interest_rate) * IRA_annual
# calculate the balance of the IRA for the users required minimum distribution age
balance_min_dist_age = ((((1 + interest_rate) * min_distribution_age) - 1) / interest_rate) * IRA_annual
# calculate required minimum distribution
req_min_distribution = balance_min_dist_age / distribution_period
print("Current year : {}".format(current_year))
print("Birth year : {}".format(birth_year))
print("Returement age: {}".format(retirment_age))
print("Annual contribution to IRA : {}".format(IRA_annual))
print("Years untill retirement : {}".format(year_until_retire))
print("Year unitll required minimum distribution : {}".format(year_until_min_dist))
print("Balance at retirment age : {}".format(balance_retirement_age))
print("Balance at required minimum distribution age : {}".format(balance_min_dist_age))
print("Required minimum distribution : {}".format(req_min_distribution))