Pages

Thursday, October 21, 2010

INFLATION RATE

Construct the flowchart and code the program to gauge the amount of inflation over the past year. The program asks for the price of an item (e.g. jeans) both one year ago and today. Then, it estimates the inflation rate as the difference in price divided by the price a year ago. Print out the inflation rate (in percentage value), amount of inflation, and the estimated price of the item (same item) one year from now two years form now. The increase in price of the item is estimated as the inflation rate times the current price.



#include<stdio.h>
#include<conio.h>

int main(void)
{
    float priceT, priceA,am_inflation;
    float inflation, aYrFNow, twoYrsFNow;


    clrscr();

    printf("\n\tEnter Price of Item today: ");
    scanf("%f",&priceT);

    printf("\tEnter Price of Item a year ago: ");
    scanf("%f",&priceA);

    am_inflation =priceT-priceA;
    printf("\n\n\tAmount of Inflation: P %.2f",am_inflation);

    inflation = ((am_inflation)/priceA*100);
    printf("\n\n\tInflation: %.2f %\n",inflation);

    aYrFNow = priceT+(priceT*inflation);
    printf("\n\tPrice of Item a year from now: P %.2f\n",aYrFNow);

    twoYrsFNow = aYrFNow+(aYrFNow*inflation);
    printf("\n\tPrice of item two years from now: P %.2f",twoYrsFNow);

    getch();

}

No comments:

Post a Comment