How to add cases together

How would i add these individual cases together?? This is what I have but I am not sure how to add the cases together properly. Any help is greatly appreciated!

double total = 0;
double yearTuition = 10000;

for (int i = 1; i <= year; i++)
{
switch (i)
{
case 1: cout << "Tuition for year 1" << " is $ " << tuition << endl;

case 2: yearTuition = ((tuition * .05) + tuition);
cout << "Tuition for year 2" << " is $ " << yearTuition << endl;

case 3: yearTuition = ((yearTuition * .05) + yearTuition);
cout << "Tuition for year 3" << " is $ " << yearTuition << endl;

case 4: yearTuition = ((yearTuition * .05) + yearTuition);
cout << "Tuition for year 4" << " is $ " << yearTuition << endl;

}

total = total + yearTuition * 3;
}
total += tuition;
cout << "4 year total tuition is $ " << total << endl;
What do you mean by add them together? You mean have two cases do the same thing?
Total = case 1 + case 2 + case 3 + case 4
Is there a formula for adding them together like that?
Not like you are suggesting. Why not remove the loop and switch/case entirely, and add things to a total as you go? If you really want to keep it, you could just add to a total at the end of the loop.
Something like this?? But what formula would i use to add the total up as i go?

double total = 0;
double yearTuition = 10000;

for (int i = 1; i <= year; i++)

cout << "Tuition for year 1" << " is $ " << tuition << endl;

yearTuition = ((tuition * .05) + tuition);
cout << "Tuition for year 2" << " is $ " << yearTuition << endl;

yearTuition = ((yearTuition * .05) + yearTuition);
cout << "Tuition for year 3" << " is $ " << yearTuition << endl;

yearTuition = ((yearTuition * .05) + yearTuition);
cout << "Tuition for year 4" << " is $ " << yearTuition << endl;


cout << "4 year total tuition is $ " << total << endl;
After each calculation, add the tuition to total.
Topic archived. No new replies allowed.