Advertisement
Guest User

Untitled

a guest
Jun 25th, 2019
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.74 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #pragma warning (disable: 4996)
  4.  
  5. #define KEYBOARD_PRICE 35.5
  6. #define MOUSE_PRICE 12.9
  7. #define MONITOR_PRICE 600
  8. #define PRINTER_PRICE 168
  9. #define SPEAKER_PRICE 120
  10. #define TAX_RATE 8.25/100
  11.  
  12. void main()
  13. {
  14. int quantity1, quantity2, quantity3, quantity4, quantity5;
  15. double totalKeyboard, totalMouse, totalMonitor, totalPrinter, totalSpeaker, subtotal, total, tax;
  16.  
  17. printf("Enter number of items sold:\n");
  18. printf("Keyboard > ");
  19. scanf("%d", &quantity1);
  20. printf("Mouse > ");
  21. scanf("%d", &quantity2);
  22. printf("Monitor > ");
  23. scanf("%d", &quantity3);
  24. printf("Printer > ");
  25. scanf("%d", &quantity4);
  26. printf("Speaker > ");
  27. scanf("%d", &quantity5);
  28.  
  29. totalKeyboard = KEYBOARD_PRICE *quantity1;
  30. totalMouse = MOUSE_PRICE *quantity2;
  31. totalMonitor = MONITOR_PRICE *quantity3;
  32. totalPrinter = PRINTER_PRICE *quantity4;
  33. totalSpeaker = SPEAKER_PRICE *quantity5;
  34.  
  35. subtotal = totalKeyboard + totalMouse + totalMonitor + totalPrinter + totalSpeaker;
  36. tax = subtotal * TAX_RATE;
  37. total = subtotal + tax;
  38.  
  39. printf("\n");
  40. printf("QTY DESCRIPTION UNIT PRICE TOTAL PRICE(RM)\n");
  41. printf("--- ----------- ---------- ---------------\n");
  42. printf("%d KEYBOARD 35.50 %.2lf \n", quantity1, totalKeyboard);
  43. printf("%d MOUSE 12.90 %.2lf \n", quantity2, totalMouse);
  44. printf("%d MONITOR 600.00 %.2lf \n", quantity3, totalMonitor);
  45. printf("%d PRINTER 168.00 %.2lf \n", quantity4, totalPrinter);
  46. printf("%d KEYBOARD 1200.00 %.2lf \n", quantity5, totalSpeaker);
  47. puts("");
  48. printf("SUBTOTAL = %.2lf\n", subtotal);
  49. printf("TAX = %.2lf\n", tax);
  50. printf("TOTAL = %.2lf\n", total);
  51.  
  52. puts("");
  53. system("pause");
  54. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement