At one college, the tuition for a full-time student is $8,000 per semester. It has been announced that the tuition will increase by 3 percent each year for the next 5 years. Write a program with a loop that displays the projected semester tuition amount for the next 5 years.
The program should print out the result in the form
In 1 year, the tuition will be $8002.3.
In 2 years, the tuition will be $8103.2.
In 3 years, …
In 4 years, …
In 5 years, …
(If, for example, the tuition would cost 8002.3dollars in one year, etc.)
Sample Run
In 1 year, the tuition will be $8240.0.↵
In 2 years, the tuition will be $8487.2.↵
In 3 years, the tuition will be $8741.816.↵
In 4 years, the tuition will be $9004.07048.↵
In 5 years, the tuition will be $9274.192594400001.↵
def comp_int(t, r, p):
for i in range(1, t + 1):
c_int = p * (1 + r) ** i
print('In {} years, the tuition will be ${}'.format(i, c_int))
comp_int(5, 0.03, 8000)
In 1 years, the tuition will be $8240.0
In 2 years, the tuition will be $8487.199999999999
In 3 years, the tuition will be $8741.816
In 4 years, the tuition will be $9004.07048
In 5 years, the tuition will be $9274.192594400001
Comments
Leave a comment