Hi all
This is what the problem is and I believe is wrong

Financial application: computing future tuition) Suppose that the tuition for a university is $ 10,000 this year and increases 5% every year. Write a program that uses a loop to compute the tuition in ten years. Write another program that computes the total cost of four years worth of tuition starting ten years from now.
Calculate the sum of years 11 - 12 - 13 and 14
This is what I have so far

import java.util.Scanner;
public class tuition02 {

public static void main(String [] args) {

//Declare variables
double tuition = 10000;
int year = 1;
double tuitiontotal = tuition;

while (year <= 10){
tuition = ((tuition * .05) + tuition);

System.out.println("The tuition in ten years is: " + tuition);

while (year <= 14){
tuition = tuition * 1.05;

tuitiontotal = tuitiontotal + tuition;

System.out.println("The total cost of 4 years is: " + tuitiontotal);

this is my output

The tuition in ten years is: 16288.946267774414
The total cost of 4 years is: 83717.76425901077

Process completed.
and I believe the answer is


please help

Thanks in advance

6 Years
Discussion Span
Last Post by JamesCherrill

double tuitiontotal = tuition;

Why this initial value? Don't you add all the desired values into tuitiontotal in the following loops?


you believe the answer is ...
and what IS the answer??

according to my calculator is


I have a difference of exact 10000 which is the original amount but I'm blind and don't see where is the mistake

Edited by sterno68: n/a


Look again at my previous post.
You initialise tuitiontotal to tuition, and tuition's initial value is... double tuition = 10000; !


Starting at $10,000 and increasing 5% every year...
Year #11 is $16288.95
Year #11 + #12 + #13 + #14 = $70207.39

My results were calculated using a spreadsheet,
and verified using a calculator.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.