Advertisement
desislava_topuzakova

11. Fruit Shop

Jan 22nd, 2023
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.27 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main()
  5. {
  6. string fruit, dayOfWeek;
  7. double quantity;
  8.  
  9. cin >> fruit >> dayOfWeek >> quantity;
  10.  
  11. double price = 0;
  12. if (dayOfWeek == "Saturday" || dayOfWeek == "Sunday") {
  13. if (fruit == "banana") {
  14. price = 2.7;
  15. }
  16. else if (fruit == "apple") {
  17. price = 1.25;
  18. }
  19. else if (fruit == "orange") {
  20. price = 0.9;
  21. }
  22. else if (fruit == "grapefruit") {
  23. price = 1.6;
  24. }
  25. else if (fruit == "kiwi") {
  26. price = 3;
  27. }
  28. else if (fruit == "pineapple") {
  29. price = 5.6;
  30. }
  31. else if (fruit == "grapes") {
  32. price = 4.2;
  33. }
  34. }
  35. else if (dayOfWeek == "Monday" || dayOfWeek == "Tuesday" || dayOfWeek == "Wednesday" || dayOfWeek == "Thursday" || dayOfWeek == "Friday"){
  36. if (fruit == "banana") {
  37. price = 2.5;
  38. }
  39. else if (fruit == "apple") {
  40. price = 1.2;
  41. }
  42. else if (fruit == "orange") {
  43. price = 0.85;
  44. }
  45. else if (fruit == "grapefruit") {
  46. price = 1.45;
  47. }
  48. else if (fruit == "kiwi") {
  49. price = 2.7;
  50. }
  51. else if (fruit == "pineapple") {
  52. price = 5.5;
  53. }
  54. else if (fruit == "grapes") {
  55. price = 3.85;
  56. }
  57. }
  58.  
  59. cout.setf(ios::fixed);
  60. cout.precision(2);
  61.  
  62. if (price == 0) {
  63. cout << "error" << endl;
  64. }
  65. else {
  66. cout << price * quantity << endl;
  67. }
  68. }
  69.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement