![]() |
#2
peach54602013-02-27 17:16
|
#include <iostream>
#include <iomanip>
#include <cmath>
#include <string>
using namespace std;
int main()
{
int i;
for (i=0; i<=9;i++){
double price;
double lastPrice;
double inflationRate;
cout<<"Price in "<<2005+i<<":";
cin>>price;
lastPrice=price;
cout<<"last price"<<lastPrice<<endl;
cout<<" price"<<price<<endl;
if (i>=1)
inflationRate=(price-lastPrice)/lastPrice;
cout<<inflationRate;
cout<<fixed<<showpoint;
cout<<setprecision(2);
cout<<"from "<< 2005+i <<" to " <<2005+i+1<<": ";
cout<<inflationRate*100<<"% inflation"<<endl;
}
cout << "Hello world!" << endl;
return 0;
}