Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #pragma warning (disable: 4996)
- #define KEYBOARD_PRICE 35.5
- #define MOUSE_PRICE 12.9
- #define MONITOR_PRICE 600
- #define PRINTER_PRICE 168
- #define SPEAKER_PRICE 120
- #define TAX_RATE 8.25/100
- void main()
- {
- int quantity1, quantity2, quantity3, quantity4, quantity5;
- double totalKeyboard, totalMouse, totalMonitor, totalPrinter, totalSpeaker, subtotal, total, tax;
- printf("Enter number of items sold:\n");
- printf("Keyboard > ");
- scanf("%d", &quantity1);
- printf("Mouse > ");
- scanf("%d", &quantity2);
- printf("Monitor > ");
- scanf("%d", &quantity3);
- printf("Printer > ");
- scanf("%d", &quantity4);
- printf("Speaker > ");
- scanf("%d", &quantity5);
- totalKeyboard = KEYBOARD_PRICE *quantity1;
- totalMouse = MOUSE_PRICE *quantity2;
- totalMonitor = MONITOR_PRICE *quantity3;
- totalPrinter = PRINTER_PRICE *quantity4;
- totalSpeaker = SPEAKER_PRICE *quantity5;
- subtotal = totalKeyboard + totalMouse + totalMonitor + totalPrinter + totalSpeaker;
- tax = subtotal * TAX_RATE;
- total = subtotal + tax;
- printf("\n");
- printf("QTY DESCRIPTION UNIT PRICE TOTAL PRICE(RM)\n");
- printf("--- ----------- ---------- ---------------\n");
- printf("%d KEYBOARD 35.50 %.2lf \n", quantity1, totalKeyboard);
- printf("%d MOUSE 12.90 %.2lf \n", quantity2, totalMouse);
- printf("%d MONITOR 600.00 %.2lf \n", quantity3, totalMonitor);
- printf("%d PRINTER 168.00 %.2lf \n", quantity4, totalPrinter);
- printf("%d KEYBOARD 1200.00 %.2lf \n", quantity5, totalSpeaker);
- puts("");
- printf("SUBTOTAL = %.2lf\n", subtotal);
- printf("TAX = %.2lf\n", tax);
- printf("TOTAL = %.2lf\n", total);
- puts("");
- system("pause");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement