help me create a for loop

I need help creating a for loop for this problem

a country club, which currently charges $2500 per year for membership, has announced it will increase its membership fee by 4% each year for the next six years. write a program that uses a loop to display the prjected rates for the next six years.

thank you for the help
for a=1; a<=6; a++
cout << "year" << a << "charge:"<<charge;
charge += (charge *0.04);
Last edited on
wwwiii24 how does that show the projected rates
That is for you to do. We are here to help people not to do their assignments for them. Show us some code djjuu16.
void MembershipFees()
{
for( int year = 1; year <=6; ++year )
{
int membership = 2500;
membership += (membership * 0.04);
cout << "Membership Fee =" << membership << "\t";
cout << "Year =" << year << "\n";

}

}

this is what i have what am i doing wrong?
you should declare membership outside of the for loop. Also membership you have declared as an integer and you are trying to give it a floating-point value. You should change the data type to a doulbe instead of an integer.
what do you mean?
i think i got it to work
void MembershipFees()
{
int membership = 2500;
for( int year = 1; year <=6; ++year )
{
membership += (membership * 0.04);
cout << "Membership Fee =" << membership << "\t";
cout << "Year =" << year << "\n";

}

}
this look better?
Which part?
1) Declaring membership outside of the loop.
2) Changing data type from integer to floating-point/double?


1
2
3
double membership = 2500.0;

//loop here 



*edit just noticed the other 2 messages.

That is almost correct. Now change the type from int to double on the 3rd line.
Last edited on
Topic archived. No new replies allowed.