Advertisement
DidiMilikina

07. Fruit Shop

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