Tuesday, 25 August 2015

Write a program that outputs inflation rates for two successive years and whether the inflation is increasing or decreasing. Ask the user to input the current price of an item and its price one year and two years ago. To calculate the inflation rate for a year, subtract the price of the item for that year from the price of the item one year ago and then divide the result by the price a year ago. Your program must contain at least the following functions: a function to get the input, a function to calculate the results, and a function to output the results. Use appropriate parameters to pass the information in and out of the function. Do not use any global variables.

#include "stdafx.h"
#include<iostream>
using namespace std;
void input(int price ,int one_year);
void result(int price ,int one_year);
void output(int inflation);
void main()
{
      int a=0,b=0,price=0,one_year=0,inflation=0;
      input (a,b);
     
     
      system("pause");
}
void input(int price ,int one_year)
{
     
      cout<<"enter the current price"<<endl;
      cin>>price;
      cout<<"enter the old price"<<endl;
      cin>>one_year;
      result(price,one_year);
}
void result(int price ,int one_year)
{
      int inflation;
 inflation=(price-one_year)/one_year;
 output(inflation);

}
void output(int inflation)
{
      cout<<"inflation rate"<<inflation<<endl;

}

1 comment: