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:
#include <stdio.h>
main ()
{
double price, per_increase, yearEnd;
int year;
printf("Enter price: ");
scanf("%lf", &price);
printf("Enter %% inflation: ");
scanf("%lf", &per_increase);
yearEnd = price;
year = 1;
while (yearEnd <= (2*price))
{
yearEnd= yearEnd + ((yearEnd * per_increase)/100);
printf("\n Year %3.2d | Inflation Price %6.2lf\n", year, yearEnd );
year++;
}