In your economics class, you are studying the purchasing power of money. Over ti
ID: 3679199 • Letter: I
Question
In your economics class, you are studying the purchasing power of money. Over time, the cost of items tends to go up (e.g., inflation), although sometimes prices may drop (e.g., deflation).
Use the Web to research price comparisons of items that are commonly purchased. For example, you may want to explore the US Census Bureau’s 2012 Statistical Abstract site (http://www.census.gov/compendia/statab/) to locate current and past price indexes on food, fuel, or housing.
Write a program that inputs an item’s description, a past year, a past price, a current year, and a current price. Make sure your program can handle multi-word descriptions.
The program should then calculate the percent change between the past and current prices and display a report. Your report should have the following characteristics:
• All prices must be formatted to display two decimal places.
• Percent change must be formatted to display one decimal place.
• All report labels must be left aligned, and all report values must be right aligned.
• The report must contain a heading that includes the years being compared.
Sample output:
Enter description: Potato Chips
Past Year: 2000
Past Year Price: 3.44
Current Year: 2010
Current Year Price: 4.74 Price Comparison: 2000 to 2010
Item: Potato Chips
Past Year: 2000 Past Year Price: 3.44
Current Year: 2010
Current Year Price: 4.74
Percent change: 37.8%
Explanation / Answer
#include<stdio.h>
void main()
{
char desc[100];
int py,cy;
int comp;
float pyP,cyP;
printf("Enter Your description: ");
scanf("%s",desc);
printf("Past Year : ");
scanf("%d",&py);
printf("Past Year Price : ");
scanf("%f",&pyP);
printf("Current Year ");
scanf("%d",&cy);
printf("current Year Price ");
scanf("%f",&cyP);
comp=pyP-cyP;
printf("Price Comparison: %d to %d is ",py,cy);
printf("Item is :%s",desc);
printf("past year is %d",py);
printf("Past year price is %f",pyP);
printf("Curent year is : %d",cy);
printf("Curent year price is %f",cyP);
printf("The diff is : %d",comp);
}