DoGy70

Untitled

May 11th, 2023
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.22 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <string.h>
  3.  
  4. #define CHAIR_PRICE 13.99
  5. #define TABLE_PRICE 42.00
  6. #define GLASS_PRICE 5.98
  7. #define CUTLERY_PRICE 21.02
  8.  
  9. int main() {
  10. int numGuests;
  11. char item[10];
  12. double totalCost = 0.0;
  13. double price_table_for_one = TABLE_PRICE / 8;
  14. double one_pair_glass = GLASS_PRICE / 6;
  15. double one_pair_cutlery = CUTLERY_PRICE / 6;
  16.  
  17. printf("Enter the number of guests: ");
  18. scanf("%d", &numGuests);
  19.  
  20. while (1) {
  21. printf("Enter an item (or 'PARTY!' to stop): ");
  22. scanf("%s", item);
  23.  
  24. if (strcmp(item, "PARTY!") == 0) {
  25. break;
  26. }
  27. if (item == "chair") {
  28. totalCost += CHAIR_PRICE * numGuests;
  29. } else if (item == "table") {
  30. totalCost += price_table_for_one * numGuests;
  31. } else if (item == "glass") {
  32. totalCost += one_pair_glass * numGuests;
  33. } else if (item == "cutlery") {
  34. totalCost += one_pair_cutlery * numGuests;
  35. }
  36. }
  37.  
  38. // Add the cost for each guest
  39. // totalCost += (numGuests * GLASS_PRICE) + ((numGuests / 8) * CUTLERY_PRICE);
  40.  
  41. printf("Total cost for organizing the party: $%.2lf\n", totalCost);
  42.  
  43. return 0;
  44. }
  45.  
Advertisement
Add Comment
Please, Sign In to add comment