Advanced Loops (Intro JAVA) Financial application - Compute Future Tuition Promp
ID: 3810235 • Letter: A
Question
Advanced Loops (Intro JAVA) Financial application - Compute Future Tuition Prompt the user for the tuition for attending University (or any other fictitious school) and for a percentage increase each year. Have the program then print out the next 4 years worth of tuitions and at the end a sun of all the tuitions. As an example, Kean's tuition is approximately 11,000 per year, and increased has increase around 4% each year (approx from collegefactua.com). Example Print out: User Enters tuition: 11000 Year 1 11000.00 Year 2 11440.00 Year 3 11897.60 Year 4 12373.50 Total 46711.10Explanation / Answer
PROGRAM CODE:
package util;
import java.util.Scanner;
public class BitListTest {
public static void main( String[] args ) {
System.out.print("Enter tuition fee: ");
Scanner keyboard = new Scanner(System.in);
double fee = keyboard.nextDouble();
System.out.print("Enter percentage increase every year: ");
double percentageIncrease = keyboard.nextDouble();
double total = 0.0;
double yearlyFee = fee;
for(int i=0; i<4; i++)
{
yearlyFee = (yearlyFee*percentageIncrease*(i))/100.0 + fee;
System.out.println("Year " + (i+1) + " " + yearlyFee);
total += yearlyFee;
}
System.out.println(" Total " + total);
}
}
OUTPUT:
Enter tuition fee: 11000
Enter percentage increase every year: 4
Year 1 11000.0
Year 2 11440.0
Year 3 11915.2
Year 4 12429.824
Total 46785.024
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.