Help with inflation calculator

I need help with making a inflation calculator. So basically the user enter the price of an item,the year of inflation, the percent of inflation. The output is to show the inflation rate of the item up to that year. So if the user enter $10, 5 years at 2.5% inflation rate. The program would show the rate from year 1 through year 5.

I wrote a program already but it only calculated for that year. I need to make it so it show the inflation rate up to that year.



#include <iostream>
using namespace std;

int main()
{
double cost, inflation,result_price=0;
int number_year, i=2;

cout<<"Enter the cost for the item: ";
cin>>cost;
cout<<"Enter the number of years: ";
cin>>number_year;
cout<<"Enter the rate of inflation: ";
cin>>inflation;

inflation= inflation/100;
result_price=cost*(1.0+inflation);

while(i<=number_year)
{result_price = result_price*(1.0+inflation);
i=i++;}

cout << result_price << endl;

return 0;



}

add this loop

1
2
3
4
5
6
7
8
9
10
int main()
{
     blah blah blah...
     int years = 0; // This is number of years
     for(int n = 0;n < years;n++)
     {
           //code here
      }
      return 0;
}


please use code tags
Topic archived. No new replies allowed.