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 one-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 percentage, for example 5.3 for 5.3%.
#include<iostream>
#include<cmath>
using namespace std;
double inflationMethod(double previousCost,double currentCost);
void main()
{
double previousCost,currentCost,rate;
char option;
do
{
cout<<"Enter previous year cost of the item:";
cin>>previousCost;
cout<<"Enter present year cost of the item:";
cin>>currentCost;
rate = inflationMethod(previousCost,currentCost);
cout<<"Rate of inflation:"<<rate*100<<"%"<<endl;
cout<<"To continue then enter 'Y':";
cin>>option;
}while((option=='Y')||(option=='y'));
}
double inflationMethod(double previousCost,double currentCost)
{
return ((currentCost - previousCost)/currentCost);
}
Output screen shot:
The code doesnt even work
Code updated....Now running code perfectly...
Domestication was one of the major campaign message of a political party in Ghana. All it means is buy and eat what you produce locally. The government has decided to impose 200% tax on all imported food which can be produced locally. Upon discussion with various stake holders, it was agreed that the tax should be reduced to 120%. On a trial basis the following food items were tagged as the base for the comparison [yam, maize, rice, millet, plantain, cassava] you are to write a c++ program that will
a) Request for the name, price of imported food item and compare with the base.
b) a tax of 5% is imposed on every food item, however if the imported food is in the
base when compared, then an extra 120% tax based on the tax charged is added.
c) Display the following results
1. name of food item
2. normal tax charged
3. extra tax charged if any
Post the discussion to improve the above solution.