Adding yearly percent increase

I can not figure out how to get my program to add each year's rate increase to the following year. Here is my code so far and any help will be be greatly appreciated.

// A country club, which currently charges $2,500
// per year for memebership, 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 projected rates for the next
// six years.

#include <iostream>

using namespace std;

int main ()
{
int year;
int membership;
float projected = 0;

cout <<"Year Projected Membership Rate" << endl;
cout <<"_______________________________________________" << endl;

for (year =1; year <=6; year++)
{
membership = 2500;
projected = ((membership) * (.04) + (membership));

cout << year <<" \t\t "<< projected << endl;
}
return 0;
}
you're not updating membership each year, it uses the original value of 2500 every loop to calculate the next year's membership. Assign membership the value of projected every loop, and dont set membership to 2500 each loop just initialise it with 2500 and remove that line from the for loop
Last edited on
Topic archived. No new replies allowed.