(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:
# Initialize the variables
tuitionFee = 10000
annualIncrease = 0.05
# Calculate the tuitionFee in ten years
for _ in range(10):
tuitionFee += tuitionFee * annualIncrease
# Calculate the total cost of four years' worth of tuitionFee starting ten years from now
totalCost = 0
for _ in range(4):
totalCost += tuitionFee
tuitionFee += tuitionFee * annualIncrease
# Display the results
print("Tuition Fee in ten years:", tuitionFee)
print("Total cost of four years' worth of tuition starting ten years from now:", totalCost)
Executed Output:
Tuition Fee in ten years: 19799.31599439397
Total cost of four years' worth of tuition starting ten years from now: 70207.39453239119