(Financial application: compute future tuition) Suppose that the tuition for a university is $10,000 this year and increases 5% every year. Write a program that computes the tuition in ten years and the total cost of four years’ worth of tuition
starting ten years from now.
Financial application: compute future tuition Program code:
tuition = 10000 # Initial tuition
increaseRate = 0.05 # Annual tuition increase rate
# Compute the tuition in ten years
for _ in range(10):
tuition += tuition * increaseRate
# Compute the total cost of four years' worth of tuition starting ten years from now
totalCost = 0
for _ in range(4):
totalCost += tuition
tuition += tuition * increaseRate
# Display the results
print("The tuition in ten years will be:", tuition)
print("The total cost of four years' worth of tuition starting ten years from now will be:", totalCost)
Executed Output:
The tuition in ten years will be: 19799.31599439397
The total cost of four years' worth of tuition starting ten years from now will be: 70207.39453239119