Write a JAVA program Suppose that the tuition for a universi

Write a JAVA program

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 ten years and the total cost of four years\' worth of tuition after the tenth year.

Solution

/**
* Financial tution fee calculator calculating fees for 10 years from now.
*/
public class TutionFee {

   /**
   * Return next year fees based on increase given as percent
   * @param currentFee current year fee
   * @param increase percent increase in fees
   * @return next year fees relative to current year fees
   */
   public static double nextYearFees(double currentFee, double increase)
   {
       return (currentFee + currentFee*increase/100);
   }
  
   public static void main(String[] args)
   {
       int tenYear = 10;
      
       double initialTutionFee = 10000;
       double increase = 5;
      
       double tenthYearFees = initialTutionFee;
      
       for(int i = 0; i < tenYear; i++)
       {
           tenthYearFees = nextYearFees(tenthYearFees, increase);
       }
      
       System.out.printf(\"Tution fees after 10 year: $%.2f\ \", tenthYearFees);
      
       double totalCollegeFees = tenthYearFees;
      
       for(int i = 0; i < 3; i++)
       {
           tenthYearFees = nextYearFees(tenthYearFees, increase);
           totalCollegeFees += tenthYearFees;
       }
      
       System.out.printf(\"Total fees of 4 year of college starting from 10th year from now: $%.2f\", totalCollegeFees);
   }
  
}

Write a JAVA program 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. Writ

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site