Print either "fruit", "drink", or "unknown" (followed by a newline) depending on the value of useritem. print "unknown" (followed by a newline) if the value of useritem does not match any of the defined options. for example, if useritem is gr_apples, output should be:

QUESTION POSTED AT 01/06/2020 - 12:35 PM

Answered by admin AT 01/06/2020 - 12:35 PM

According to your syntax, I am pretty sure that this one is C++ question. I think that your solution looks like this:
So if useritem is gr_apples, output should be "Fruit".
int main() {   enum GroceryItem {GR_APPLES, GR_BANANAS, GR_JUICE, GR_WATER};
   GroceryItem userItem = GR_APPLES; if((userItem == GR_APPLES) || (userItem == GR_BANANAS)){ cout << "Fruit"; } else if((userItem == GR_JUICE) || (userItem == GR_WATER)){ cout << "Drink"; } else{ cout << "Unknown"; }
cout << endl;   return 0;}
Post your answer

Related questions