Question: C++ help! Write a program to gauge the rate of inflation for the past year. The program asks for the price of an item (such

C++ help! Write a program to gauge the rate of inflation for the past year. The program asks for the price of an item (such as a hot dog or a 1-carat diamond) both one year ago and today. It estimates the inflation rate as the difference in price divided by the year-ago price. Your program should allow the user to repeat this calculation as often as the user wishes. Define a function to compute the rate of inflation. The inflation rate should be a value of type double giving the rate as a percent, for example 5.3 for 5.3 percent

In int main() ask the user to enter cost of the item last year and current cost. Call a function that calculates the inflation rate and returns its value. Here's what I have:

#include  using namespace std; double calcInflation(double current_cost, double previous_cost ); int main() { //cout << "Hello world!" << endl; double cost_lastyear, cost_thisyear; char c; do{ // write statements which take input from the user double inflation = calcInflation(cost_thisyear, cost_lastyear); // write statement which prints inflation rate }while(); return 0; } double calcInflation(double current_cost, double previous_cost ){ //function definition goes here } 

**Sample Output:

Enter the cost of 1 - Carat Diamond last year 200000 Enter the current cost of 1 - Carat Diamond 400000 
Inflation rate is 100 percent Do you want to continue ?(Y/N) Y Enter the cost of 1 - Carat Diamond last year 150000 
Enter the current cost of 1 - Carat Diamond 200000 Inflation rate is 33.3333 percent Do you want to continue ?(Y/N) 

N.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!