**5.7 (Financial application: compute future tuition) 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 computes the tuition in ten years and the total cost of four years’ worth of tuition after the tenth year.
public class ProgrammingEx5_7 { public static void main(String[] args) { int feePerYear = 10000; int totalFee = 0; for (int i = 1; i <= 14; i++) { feePerYear += feePerYear * .05; // at year ten if (i == 10) { System.out.println("The tuition fee in ten year is $" + feePerYear); } // sumation of fee over the next 4 years if (i > 10) { totalFee = totalFee + feePerYear; } } System.out .println("The total cost of 4 years tuition after the tenth year is $" + totalFee); } }
how it could be 73000 after 4 years haha
ReplyDelete