Answer:
#include
using namespace std;
void getInput(double currentPrice, double priceYear1, double priceYear2){
cin >> currentPrice;
cin >> priceYear1;
cin >> priceYear2;
}
void printInflationRate( double myRate){
cout<< "The inflation rate for the year price = "<< rate;
}
void calInflation(double targetPrice, double yearBefore){
double rate = (yearBefore - targetPrice)/ yearBefore;
printInflationRate( rate);
}
int main(){
double cprice, year1price, year2price, rate;
getInput(cprice, year1price, year2price);
calInflationRate(cprice, year1price);
calInflationRate(year1price, year2price);
return 0;
}
Explanation:
The C++ program source code defines three void functions (functions with no return statement), 'calInflationRate', 'getInput', and printInflationRate. In the main program code, the four float point number variables are declared, and the getInput function assigns values to them. The calInflationRate function calculates the inflation rate of a given year, and it in, the printInflationRate is called to print the output on the screen.