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;

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

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


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

tuitiontotal = tuitiontotal + tuition;
year++;
}

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

73717.76425901076

please help

Thanks in advance

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

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

73717.76425901076

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

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

Member Avatar

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.

How is this done in C++ instead of JAVA?

Please do not hijack old threads. Start a new thread for your question, and this is not the best forum for C++