Advertisement
DidiMilikina

07. Fruit Shop

Oct 1st, 2017
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.01 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3. #include <iomanip>
  4.  
  5. using namespace std;
  6.  
  7. int main()
  8. {
  9.  
  10.     double quantity;
  11.     string day, fruits;
  12.  
  13.     cin >> fruits >> day >> quantity;
  14.  
  15.     bool is_it_incorrect_day = "Monday" || "Tuesday" || "Wednesday" || "Thursday" || "Friday" || "Saturday" || "Sunday";
  16.     bool is_it_incorrect_fruit = "banana" || "apple" || "orange" || "grapefruit" || "kiwi" || "pineapple" || "grapes";
  17.  
  18.     if (day == "Monday" || day == "Tuesday" || day == "Wednesday" || day == "Thursday" || day == "Friday")
  19.     {
  20.         if (fruits == "banana") cout << fixed << setprecision(2) << 2.5 * quantity << endl;
  21.         else if (fruits == "apple") cout << fixed << setprecision(2) << 1.2 * quantity << endl;
  22.         else if (fruits == "orange") cout << fixed << setprecision(2) << 0.85 * quantity << endl;
  23.         else if (fruits == "grapefruit") cout << fixed << setprecision(2) << 1.45 * quantity << endl;
  24.         else if (fruits == "kiwi") cout << fixed << setprecision(2) << 2.7 * quantity << endl;
  25.         else if (fruits == "pineapple") cout << fixed << setprecision(2) << 5.5 * quantity << endl;
  26.         else if (fruits == "grapes") cout << fixed << setprecision(2) << 3.85 * quantity << endl;
  27.         else cout << "error" << endl;
  28.     }
  29.  
  30.     else if (day == "Saturday" || day == "Sunday")
  31.     {
  32.         if (fruits == "banana") cout << fixed << setprecision(2) << 2.7 * quantity << endl;
  33.         else if (fruits == "apple") cout << fixed << setprecision(2) << 1.25 * quantity << endl;
  34.         else if (fruits == "orange") cout << fixed << setprecision(2) << 0.90 * quantity << endl;
  35.         else if (fruits == "grapefruit") cout << fixed << setprecision(2) << 1.60 * quantity << endl;
  36.         else if (fruits == "kiwi") cout << fixed << setprecision(2) << 3.0 * quantity << endl;
  37.         else if (fruits == "pineapple") cout << fixed << setprecision(2) << 5.6 * quantity << endl;
  38.         else if (fruits == "grapes") cout << fixed << setprecision(2) << 4.2 * quantity << endl;
  39.         else cout << "error" << endl;
  40.     }
  41.  
  42.     else if (is_it_incorrect_day || is_it_incorrect_fruit)
  43.     {
  44.         cout << "error" << endl;
  45.     }
  46.  
  47.     return 0;
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement