Hello,
I am trying to do the following:
Company needs 200 pens a year. Write a program to gauge the expected cost of an item in a specific number of years. Asks for the cost of the item, numbers of years from now it will be purchased, and the rate of inflation. It outputs the estimated cost of the item after the specific period. Have the user enter the inflation rate as a percentage. Program needs to convert the percentage to a fraction, and should use a loop to estimate the price adjusted for inflation.
What I have right now is this, but I have to use a loop actually..
#include <iostream>
#include <cmath>
using namespace std;
int main() {
double CostOfItem;
double NumberYears;
double Inflation;
double Result;
cout << " What's the cost of the item ? : " ;
cin >> CostOfItem ;
cout << " Number of years from now that the item will be purchased: " ;
cin >> NumberYears ;
cout << " Enter the rate of Inflation: " ;
cin >> Inflation ;
// Result = CostOfItem*Inflation^X
Result = pow(CostOfItem * (1 + Inflation/100), NumberYears);
cout << Result << endl;
return 0;
}
How do I use a loop here? Can someone tell me in words how the loop is supposed to look like? I think I have to initialize to 0 first. Then somehow implement the equation... no idea.
Help is appreciated!