A department store is having a closeout sale on all its merchandise. Write a program that will prompt the user to enter 5 regular price item's and the percentage of the discount that should be given to that item. Store all prices and discount percentages and calcuated sales price in one array. Display the original prices, the discount rates, and the corresponding sale prices. The output should be formatted similar to the following. Price Discount Sale price 3.50 .25 xx.xx 4.00 .50 xx.xx 5.25 .25 xx.xx 6.00 .30 xx.xx 10.45 .33 xx.xx
Nobody will do your homework for you, but here are some tips and sample code: 1. Create a structure representing an item with required fields. Code: typedef struct { double price; double discount; double sale_price; } item_t; 2. Define 5-element array of item-type above. Code: #define ITEMS_COUNT 5 item_t stock[ITEMS_COUNT]; 3. Input data in a loop. Code: int i; for (i = 0; i < ITEMS_COUNT; i++) { // input [I]stock[[/I][I]i].price[/I] and [I]stock[[/I][I]i].discount[/I] using [I]scanf()[/I] stock[i].sale_price = stock[i].price - stock[i].price * stock[i].discount; } 4. Display data in a loop. Code: printf("Price \t Discount \t Sale price \n"); for (i = 0; i < ITEMS_COUNT; i++) { printf("%.2lf \t %.2lf \t %.2lf \n", stock[i].price, stock[i].discount, stock[i].sale_price); }