The question is: Suppose that the tuition for a university is $10,000 this year and increases 5% every year. Write a program that computes the tuition in ten years and the total cost of four years' worth of tuition starting ten years from now.
The correct answers to this program should be:
The tuition after 10 years is $16288.9
Tuition in year 1 is $16288.9
Tuition in year 2 is $17103.4
Tuition in year 3 is $17958.6
Tuition in year 4 is $18856.5
4 year total tuition is $70207.4
I have wrote the first part of the program but am not sure how to go from here. Any help is appreciated! This is what I have so far:
#include<iostream>
using namespace std;
int main ()
{
double tuition = (10000);
int year = 1;
for (int i = 1; i <= 10; i++)
{
tuition = ((tuition * .05) + tuition);
}
cout << "Tuition after 10 years is: " << tuition << endl;
I am not sure whether this is what you need for the assignment. If it is not, maybe it is something similar to what I wrote. PLEASE NOT TO BE plagiarized. Try to look through what I have, and then write your own codes.
int main ( )
{
const double tuition = 16288.9;
int year = 4;
cout << "The tuition after 10 years is $ " << tuition << endl;
double total = 0;
double yearTuition = 0;
for (int i = 1; i <= year; i++)
{
switch (i)
{
case 1: cout << "Tuition in year 1" << " is $ " << tuition << endl;
break;
case 2: yearTuition = ((tuition * .05) + tuition);
cout << "Tuition in year 2" << " is $ " << yearTuition << endl;
break;
case 3: yearTuition = ((yearTuition * .05) + yearTuition);
cout << "Tuition in year 3" << " is $ " << yearTuition << endl;
break;
case 4: yearTuition = ((yearTuition * .05) + yearTuition);
cout << "Tuition in year 4" << " is $ " << yearTuition << endl;
break;
}
total = total + yearTuition;
}
total += tuition;
cout << "4 year total tuition is $ " << total << endl;
system ("pause");
return 0;
}
The tuition after 10 years is $ 16288.9
Tuition in year 1 is $ 16288.9
Tuition in year 2 is $ 17103.3
Tuition in year 3 is $ 17958.5
Tuition in year 4 is $ 18856.4
4 year total tuition is $ 53918.3
Press any key to continue . . .
Thanks for the help! I am still having trouble coming out with the right 4 year amount I am getting 72,858.4 and the answer should be 70,207.4 I not sure what i am doing wrong. I need help fixing this formula to calculate the right amount.
}
total = total + yearTuition * 3;
}
total += tuition;
cout << "4 year total tuition is $ " << total << endl;