Advertisement
wigllytest

Untitled

Aug 7th, 2020
139
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.89 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3.  
  4.  
  5. using namespace std;
  6.  
  7. int main() {
  8.  
  9. string fruit, dayOfWeek;
  10. double quantity, price;
  11. cin >> fruit >> dayOfWeek >> quantity;
  12.  
  13. price = 0;
  14. cout.setf(ios::fixed);
  15. cout.precision(2);
  16.  
  17. if (dayOfWeek == "Monday" || dayOfWeek == "Tuesday" || dayOfWeek == "Wednesday" || dayOfWeek == "Thursday" || dayOfWeek == "Friday")
  18. {
  19. if (fruit == "banana")
  20. {
  21. price = 2.5 * quantity;
  22. cout << price;
  23. }
  24. else if (fruit == "apple")
  25. {
  26. price = 1.2 * quantity;
  27. cout << price;
  28. }
  29. else if (fruit == "orange")
  30. {
  31. price = 0.85 * quantity;
  32. cout << price;
  33. }
  34. else if (fruit == "grapefruit")
  35. {
  36. price = 1.45 * quantity;
  37. cout << price;
  38. }
  39. else if (fruit == "kiwi")
  40. {
  41. price = 2.7 * quantity;
  42. cout << price;
  43. }
  44. else if (fruit == "pineapple")
  45. {
  46. price = 5.5 * quantity;
  47. cout << price;
  48. }
  49. else if (fruit == "grapes")
  50. {
  51. price = 3.85 * quantity;
  52. cout << price;
  53. }
  54. else
  55. {
  56. cout << "error" << endl;
  57. }
  58. }
  59. else if (dayOfWeek == "Saturday" || dayOfWeek == "Sunday")
  60. {
  61. if (fruit == "banana")
  62. {
  63. price = 2.7 * quantity;
  64. cout << price;
  65. }
  66. else if (fruit == "apple")
  67. {
  68. price = 1.25 * quantity;
  69. cout << price;
  70. }
  71. else if (fruit == "orange")
  72. {
  73. price = 0.90 * quantity;
  74. cout << price;
  75. }
  76. else if (fruit == "grapefruit")
  77. {
  78. price = 1.6 * quantity;
  79. cout << price;
  80. }
  81. else if (fruit == "kiwi")
  82. {
  83. price = 3 * quantity;;
  84. cout << price;
  85. }
  86. else if (fruit == "pineapple")
  87. {
  88. price = 5.6 * quantity;
  89. cout << price;
  90. }
  91. else if (fruit == "grapes")
  92. {
  93. price = 4.2 * quantity;
  94. cout << price;
  95. }
  96. else
  97. {
  98. cout << "error" << endl;
  99. }
  100. }
  101. else
  102. {
  103. cout << "error" << endl;
  104. }
  105.  
  106.  
  107. //cout.setf(ios::fixed);
  108. //cout.precision(2);
  109.  
  110. //cout << price * quantity << endl;
  111.  
  112. return 0;
  113. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement