Suppose that the tuition for a university is $10,000 this year and increases 5% every year. In one year, the tuition will be $10,500. Write a program that displays the tuition in 10 years and the total cost of 4 years worth of tuition starting after the 10th year.

LANGUAGE: Python

CHALLENGE:

Suppose that the tuition for a university is $10,000 this year and increases 5% every year. In one year, the tuition will be $10,500. Write a program that displays the tuition in 10 years and the total cost of 4 years’ worth of tuition starting after the 10th year.

SOLUTION:

tuition = 10000
tuition_10 = tuition * (1.05 ** 10)

print("Tuition in 10 years is ${:.2f}".format(tuition_10))

total = 0
for i in range(4):
    total += tuition_10
    tuition_10 *= 1.05

print("Total cost of four years is ${:.2f}".format(total))

Posted in ,