the question -
Write a C program to create a customer’s bill for a company. The company ARAFAT sells only five different products. They are TV, VCR, Remote Controller, CD Player and Tape Recorder. The unit prices are $400.00, $220.00, $35.20, $300.00 and $150.00, respectively. The program must read the quantity of each piece of equipment purchased from the keyboard as shown below. It then calculates the cost of each item, the subtotal, the tax amount and the total cost after deduct the sale tax. 8.25% sales tax is applied.
The input data which is the quantity of each item sold is to be input into the program as an integer. The program must prompt the user for each quantity in a user friendly way as shown below. The numbers in boldface show the user’s entries.
SAMPLE OUTPUT
How Many TVs Were Sold? 3
How Many VCRs Were Sold? 5
How Many Remote Controllers Were Sold? 1
How Many CDs Were Sold? 2
How Many Tape Recorders Were Sold? 4
QTY DESCRIPTION UNIT PRICE TOTAL PRICE
--- ----------- ---------- -----------
XX TV 400.00 $ XXXX.XX
XX VCR 220.00 $ XXXX.XX
XX REMOTE CTRLR 35.20 $ XXXX.XX
XX CD PLAYER 300.00 $ XXXX.XX
XX TAPE RECORDER 150.00 $ XXXX.XX
-----------
SUBTOTAL $ XXXX.XX
TAX $ XXXX.XX
TOTAL $ XXXX.XX
this is my code -
Code:
#include<stdio.h>
#define tax 8.25
#define TV_price 400.00
#define VCR_price 220.00
#define Remote_Controller_price 35.20
#define CD_Player_price 300.00
#define Tape_Recorder 150.00
void main()
{
int TV, VCR, Remote_Controller, CD_Player, Tape_Recorder;
float subtotal, total;
printf("How Many TVs Were Sold?: ");
scanf("&d" ,&TV);
printf("How Many VCRs Were Sold?: ");
scanf("&d" ,&VCR);
printf("How Many Remote Controllers Were Sold?: ");
scanf("&d" ,&Remote_Controller);
printf("How Many Cd Players Were Sold?: ");
scanf("&d" ,&CD_Player);
printf("How Many tape Recorders Were Sold?: ");
scanf("&d" ,&Tape_Recorder);
//total_price=quantity*total price
/*you might want an ext(ended) unit cost. That would be the cost for any item * the cost
of one unit. So if someone bought two vcr's, their unit price would be 220 still, but their
extended price would be 2 * 220 = 440. If you don't need to track how much was earned
from each item in the store, you may just put it all together under "sub total".
Let's say that we want to track the sales in $$$ for each item, so we use an extCD_Player, extTape Recorder,
extVCR, etc.
The total figures then would be:
if(TV > 0)
extTV = TV * TV_price;
if(VCR > 0)
extVCR = VCR * VCR_price;
if(RemoteController > 0)
extRemoteController = RemoteController * RemoteController_price;
//and same for CD player and Tape Recorder.
subtotal = extTV + extVCR +extRemoteController +extCD_Player + extTape_Recorder
total = sub_total * 1.0825 (the tax rate of 8.25)
printf("QTY DESCRIPTION UNIT PRICE TOTAL PRICE ");
printf("=== =========== ========== =========== ");
printf("%d TV 400.00 " , TV , total_price );
printf("%d VCR 220.00 " , VCR ,total_price );
printf("%d Remote Controller 35.20 " , Remote_Controller , total_price );
printf("%d CD PLayer 300.00 " , CD_Player,total_price );
printf("%d Tape Recorder 150.00 " , Tape_Recorder ,total_price );
printf(" ----------- " );
printf(" SUBTOTAL %.2f " , subtotal);
printf(" TAX %.2f " , tax);
printf(" TOTAL %.2f " , total);
getch()
}
My problem is
how can i
define Quantity so that i can calculate total_price?. thank you!