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;
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.