FINAL_PROJECT (Compound Interest)

# FINAL PROJECT

# The program ask for a user to enter the initial amount in a saving account,
#the interest rate, the nomber of years and the time interest if applicable.

# function to calculate total amount in the saving acount

def cal_saving_amount(p, r, t, n):
import math
if n==0:
r=r/100 # the three following statements are to calculate the total amount if the interest is compound continously i.e Many times over the year
amount=math.e
amount=p*(amount**(r*t))
else:
r=r/100 # the two following statements are to calculate the total amount if the interest is compound n time per year
amount=p*((1+(r/n))**(n*t))
return amount

# PROCESSING STAGE

choice=’y’
while choice ==’y’:
# enter  the initial amount, the interest rate, the number of year and the interest period if applicable
init_amount=float(input(‘Please enter the initial amount dollars in the saving account : ‘))
int_rate=float(input(‘Please enter the interest rate percentage: ‘))
nbe_year=float(input(‘Please enter the number of year :’))
compound_choice=input(‘Continuously compound (y/n)? ‘)
if compound_choice==’n’:
print(‘How many time the interest is compound per year?)’)
time_period=float(input(‘Please enter the interst period : ‘ ))
elif compound_choice==’y’:
time_period=0.0
else:
break
total_amount=cal_saving_amount(init_amount, int_rate,nbe_year, time_period)
print(”)
print(‘THE TOTAL AMOUNT IN THE SAVING ACCOUNT AFTER ‘,nbe_year, ‘ YEAR(S)INVESTMENT IS : ‘,total_amount)
print(‘  ‘)
choice=input(‘DO you want to calculate again ? ((y/n)’ )# If the user answer “y” the program ask for inputs again.
print(“GOOD BYE!!!!!!!”)