Advertisement
Nephelir

Untitled

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