#include <iostream>
#include <iomanip>
#include <string>
#include <cmath>
using namespace std;
void getInput(double& currPrice, double& oneYearPrice, double& twoYearPrice);
void calcInflation(double currPrice, double oneYearPrice, double twoYearPrice, double& infRate1, double& infRate2);
void main()
{
double infRate1;
double infRate2;
//int Years, Price, Inflation;
double currPrice, oneYearPrice, twoYearPrice;
getInput(currPrice, oneYearPrice, twoYearPrice);
calcInflation(currPrice, oneYearPrice, twoYearPrice, infRate1, infRate2);
}
void getInput(double& currPrice, double& oneYearPrice, double& twoYearPrice)
{
cout << "Enter the current price of the item: ";
cin >> currPrice;
cout << endl;
cout << "Enter the price of the item one year ago: ";
cin >> oneYearPrice;
cout << endl;
cout << "Enter the price of the item two years ago: ";
cin >> twoYearPrice;
cout << endl;
}
void calcInflation(double currPrice, double oneYearPrice, double twoYearPrice, double& infRate1, double& infRate2)
{
//twoYearPrice =(twoYearPrice - oneYearPrice)/ oneYearPrice;
infRate1 =(currPrice - oneYearPrice)/ oneYearPrice;
infRate2 =(currPrice - twoYearPrice)/ twoYearPrice;
}
I need help on the last part where it says
infRate1 =(currPrice - oneYearPrice)/ oneYearPrice;
infRate2 =(currPrice - twoYearPrice)/ twoYearPrice;
I don't understand what to do where it is to calculate the inflation rate.
heres a sample output:
Enter the current price of the item: 100.00
Enter the price of the item one year ago: 92.00
Enter the price of the item two years ago: 82.75
Current year inflation: 0.09
Inflation one year ago: 0.11
Inflation is not increasing.