In: Computer Science
A full-time student pays $8,000 per semester. It has been announced that the tuition will increase by 3 percent each year for the next three years. Write a program with a loop that displays the projected semester tuition amount for the next three years. Also, provide the option to the student to calculate the tuition for another three years using the same percent increase. Please remember, if the student decides to calculate the tuition for another three years the starting tuition will be calculated tuition value for the end of the 3-year period.
CALCULATE USING PYTHON PROGRAMMING LANGUAGE. PLEASE INCLUDE NOTES AS WELL.
# Python program to calculate semester fee
def tutionFee(fee, rate):
"""
function for calculate tution fee
@Param: fee and interest rate
Return: fee after one year
"""
# return calculate tution fee
return (fee * (1 + rate /100))
def main(currentFee, rate):
"""
function to call tution fee and display result
@Param: current fee and interest rate
Return:
"""
# initialize variable
count = 0
initial = currentFee
# display initial fee
print("Initial fee: ",currentFee)
print("")
# calculate yearwise semester fee upto 9 years
while count < 3:
# for last three years fee will be
# calculated as per initial fee
if count == 2:
currentFee = initial
# display three years semester fees
for i in range(1, 4):
# get current fee
currentFee = tutionFee(currentFee, rate)
# display fee
print("Projected Semester fee after",\
count * 3 + i,"year: ",round(currentFee, 2))
# incerement
count = count + 1
# new line
print("")
# take choice only two times
if count <= 2:
# take choice if to continue
choice = input("Do you want calculate tution fee for another 3 years (Y/N): ")
if not(str(choice) == 'Y' or str(choice) == 'y'):
# new line
print("")
break
# driver code
if __name__ == "__main__":
"""
Call main() function
"""
currentFee = 8000
rate = 3
# pass current fee
main(currentFee, rate)
___________________________________________________________________
___________________________________________________________________
Initial fee: 8000
Projected Semester fee after 1 year: 8240.0
Projected Semester fee after 2 year: 8487.2
Projected Semester fee after 3 year: 8741.82
Do you want calculate tution fee for another 3 years (Y/N): Y
Projected Semester fee after 4 year: 9004.07
Projected Semester fee after 5 year: 9274.19
Projected Semester fee after 6 year: 9552.42
Do you want calculate tution fee for another 3 years (Y/N): Y
Projected Semester fee after 7 year: 8240.0
Projected Semester fee after 8 year: 8487.2
Projected Semester fee after 9 year: 8741.82
___________________________________________________________________
Note: If you have queries or confusion regarding this question, please leave a comment. I would be happy to help you. If you find it to be useful, please upvote.