Advertisement
Guest User

Untitled

a guest
Jan 23rd, 2020
130
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.53 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <string.h>
  3.  
  4. int main ()
  5. {
  6. char strCommand[] = ""; //User type command to order calendars.
  7. double dBill = 0.00; // Bill (without discount).
  8. double iCounter = 0.00; // How many calendars were ordered.
  9. printf("\nType what kind of calendars you want to order.");
  10. printf("\nThe options are - Small, Medium, Big and Special.");
  11. printf("\nIf you order more than 3 calendars - you got 20 percent discount!");
  12. printf("\nPrices: \nSmall - 2.40 dollars \nMedium - 3.50 dollars \nBig - 6.30 dollars \nSpecial - 12.00 dollars");
  13. printf("\nType Done! when you are ready to order.\n");
  14.  
  15. do
  16. {
  17. scanf("%s", &strCommand);
  18.  
  19. if (strcmp(strCommand, "Small") == 0)
  20. {
  21. printf("Small calendar ordered.\n");
  22. dBill += 2.40;
  23. iCounter += 1;
  24. }
  25. if(strcmp(strCommand, "Medium") == 0)
  26. {
  27. printf("Medium calendar ordered.\n");
  28. dBill += 3.50;
  29. iCounter += 1;
  30. }
  31. if(strcmp(strCommand, "Big") == 0)
  32. {
  33. printf("Big calendar ordered.\n");
  34. dBill += 6.30;
  35. iCounter += 1;
  36. }
  37. if(strcmp(strCommand, "Special") == 0)
  38. {
  39. printf("Special calendar ordered.\n");
  40. dBill += 12.00;
  41. iCounter += 1;
  42. }
  43. } while (strcmp(strCommand, "Done!") != 0);
  44.  
  45. if (iCounter < 4)
  46. {
  47. printf("\nYou ordered %.0lf calendars!", iCounter);
  48. printf("\nYour bill is %.2lf dollars.", dBill);
  49. }
  50. else
  51. {
  52. dBill = dBill * 0.80;
  53. printf("\nYou ordered %.0lf calendars! You got 20 percent off!", iCounter);
  54. printf("\nYour bill is %.2lf dollars.", dBill);
  55. }
  56.  
  57. return 0;
  58. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement