desislava_topuzakova

09. Fruit or Vegetable

Jan 23rd, 2022
1,073
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.68 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main()
  5. {
  6.     string product;
  7.     cin >> product;
  8.  
  9.     //banana, apple, kiwi, cherry, lemon и grapes -> fruit
  10.     //tomato, cucumber, pepper и carrot -> vegetable
  11.     //other -> unknown
  12.  
  13.     if (product == "banana" || product == "apple" || product == "kiwi"
  14.         || product == "cherry" || product == "lemon" || product == "grapes")
  15.     {
  16.         cout << "fruit" << endl;
  17.     }
  18.     else if (product == "tomato" || product == "cucumber"
  19.         || product == "pepper" || product == "carrot")
  20.     {
  21.         cout << "vegetable" << endl;
  22.     }
  23.     else
  24.     {
  25.         cout << "unknown" << endl;
  26.     }
  27.     return 0;
  28. }
  29.  
  30.  
Advertisement
Add Comment
Please, Sign In to add comment