Advertisement
DidiMilikina

07. Fruit Shop

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