To solve the problem, we need to check if the value of userItem is a type of fruit or drink. We can do this using an if-else statement and the endsWith method of the String class to check the suffix of the value.
Here's the pseudocode to solve the problem:
If userItem ends with "APPLES", "BANANAS", or "ORANGES", output "Fruit" and a newline.
Else if userItem ends with "COFFEE", "TEA", or "SODA", output "Drink" and a newline.
Otherwise, output nothing.
Here's the corresponding Java code:
if (userItem.endsWith("APPLES") || userItem.endsWith("BANANAS") || userItem.endsWith("ORANGES")) {
System.out.println("Fruit");
} else if (userItem.endsWith("COFFEE") || userItem.endsWith("TEA") || userItem.endsWith("SODA")) {
System.out.println("Drink");
} else {
// do nothing
}
Note that we're using the || (or) operator to check if the value ends with any of the specified fruits or drinks. If it does, we output the corresponding type. If not, we do nothing.