Student Programmer needs help help with for loop

The program is a membership fee increase program.
We are suppose to write a program that displays a fee increase of 4% every year for 6 years. This is where I have given up.

1
2
3
4
 for ( year, fee; year <= end; year++, fee *=.04)
{
 cout << year <<setw(13)<< fixed << setprecision(2) << fee  << endl;
 }
1
2
3
4
5
6
int fee = 10; //You didn't say how much the fee started as.
for (int year = 0\1; i <= end; year++)
{
fee = fee * 1.04;
//At this point, use whatever cout you want, the fee is simply called fee, year is called year
}
2500
Its a bit of a difficult task to guess why you gave up. But I would make a guess that you need to add the 4% to the existing fee, which will make the fee grow somewhat larger each year.

You could do that in two different ways.
Here it is shown in full: fee = fee + fee*.04;
There is also a more concise way of expressing it, by combining 100% + 4% into a single figure of 104%, like this: fee *= 1.04;
These both achieve the same result.
Topic archived. No new replies allowed.