# Ch4_5 - /************************************************/

This preview shows page 1. Sign up to view the full content.

#include <iostream.h> #include <conio.h> /************************************************** Name: Hung Truong Program: Instructor: Mr. Barkeshli Purpose: Chapter 4_5: Inflation rate over years Input: Prices one year ago and today Output: Inflation rate, estimated price next year **************************************************/ bool t=true; char c; double last, now,rt; double irate(double previous, double today); //Calculate the inflation rate by price of last year and today double eprice(double price,double rate, int year); //Estimate the price by inflation rate in years main() { cout.setf(ios::fixed); cout.setf(ios::showpoint); cout.precision(2); while (t==true) { cout<<"Enter price of hot dog at PCC last year: ";cin>>last; cout<<"Enter price of hot dog at PCC today: ";cin>>now;
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: /************************************************/ cout<<"Inflation Rate: "<<100*irate(last,now)<<endl; rt=irate(last,now); cout<<"Estimated price of hot dog at PCC next year: "<< eprice(now,rt,1)<<endl; cout<<"Estimated price of hot dog at PCC next 2 year: "<< eprice(now,rt,2)<<endl; /************************************************/ cout<<"You want to do it again(Y/N)? ";cin>>c; t=(c=='Y')|(c=='y'); } } double irate(double previous, double today) { double temp; temp=(today-previous)/previous; return temp; } double eprice(double price, double rate, int year) { double temp=price; int i; for (i=1;i<=year;i++) temp=temp*(1+rate); return temp; }...
View Full Document

## This note was uploaded on 03/20/2011 for the course CS 2 taught by Professor Barkeshli during the Spring '11 term at Pasadena City College.

Ask a homework question - tutors are online