All pastes #799414 Raw Edit

Dark3Lite

public text v1 · immutable
#799414 ·published 2007-11-27 16:59 UTC
rendered paste body
The price of an item is p dollars. Due to inflation , the price of the item is expected to increase by r% each year. For example, the price might be $79.50 and the inflation might be 7.5 %. Write a program which reads values for p & r, and , starting with year 1, prints a table consisting of year and year-end price. The table ends when the year-end price is at least twice the original price.

Look what I have thus far: 


/*   Name:  Price Increase
     Copyright: 2007
     Author: Wesley
     Description: Price increase of an item yearly


*/

#include <stdio.h>

main ()

{
     double price, per_increase, yearEnd;
     int year;
     
     yearEnd = price;
     year = 1;
     printf("Enter price: ");
     scanf("%lf", &price);
         
     printf("Enter %% increase: ");
     scanf("%lf", &per_increase);
     
     while (yearEnd <= (2*price))
     {     
     yearEnd= yearEnd + ((yearEnd * per_increase)/100);
     
     }
     printf("The increase in %d years is %3.2lf", year, yearEnd );
     
     year++;


}