Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write a program that outputs inflation rates for two successive years and whethe

ID: 3598912 • Letter: W

Question

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. (check for input failure)(C++)

each function has a brief description

Use proper indentation in if /switch statements

Use proper indentation in while/do-while/for statement

main function consists of only function calls
NOTE: there should be no loops or if statements in the main

each function has a brief description

Explanation / Answer

code:

#include<iostream>
using namespace std;
void fuc(int a,int b,int c);
void prin(float l,float k);
void functio()
{
int a,b,c;
cout<<"enter the cost price for given year"<<" ";
cin>>a;
cout<<"enter the cost price a year before"<<" ";
cin>>b;
cout<<"enter the cost price two years before"<<" ";
cin>>c;
fuc(a,b,c);
}
void fuc(int a,int b,int c)
{
float k=c-b/float(c);
float l=b-a/float(b);
prin(l,k);

}
void prin(float l,float k)
{


cout<<"inflation a year ago is "<<"-->"<<l<<" ";
cout<<"inflation two years ago is "<<"-->"<<k<<" ";
if(k>l)
{

cout<<"inflation rate is increased"<<endl;
}
else
{

cout<<"inflation rate is decreased"<<endl;
}
}
int main()
{
functio();

}

output:

enter the cost price for given year
10
enter the cost price a year before
11
enter the cost price two years before
12
inflation a year ago is -->10.0909
inflation two years ago is -->11.0833
inflation rate is increased

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote