1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
kupik [55]
3 years ago
15

Print either "Fruit", "Drink", or "Unknown" (followed by a newline) depending on the value of userItem. Print "Unknown" (followe

d by a newline) if the value of userItem does not match any of the defined options. For example, if userItem = GR_APPLES, output should be:FruitSample program:#include using namespace std;int main() { enum GroceryItem {GR_APPLES, GR_BANANAS, GR_JUICE, GR_WATER}; GroceryItem userItem = GR_APPLES; return 0;}Below, do not type an entire program. Only type the portion indicated by the above instructions (and if a sample program is shown above, only type the portion.)

Computers and Technology
1 answer:
vagabundo [1.1K]3 years ago
7 0

Answer:

I am writing a C++ program. Let me know if you want the program in some other programming language. Here is the portion of the code:

if((userItem == GR_APPLES) || (userItem == GR_BANANAS)){

 cout << "Fruit";   }

else if((userItem == GR_JUICE) || (userItem == GR_WATER)){

 cout << "Drink";  }

else{

 cout << "Unknown";  }  

cout << endl;

 

Explanation:

The IF statement is used to check the defined options with the value in the userItem.

If the value of the userItem is GR_APPLES OR GR_BANANAS then Fruit is printed as the output. || represents a logical operator OR so this means that userItem can be either the GR_APPLES or GR_BANANAS for the If condition to evaluate to true.

If the above condition evaluates to false then the else-if part will be checked next. So the else if checks if the value in the userItem is GR_JUICE or GR_WATER. If userItem contains either of these two then Drink is displayed on the screen as output.

If the else-if statement also evaluates to false then the else part is executed which displays Unknown.

The cout<< endl; statement in the last is used to print the new line. For example if the output is Unknown then it is followed by a new line.

In the given program userItem is set to GR_APPLES

GroceryItem userItem = GR_APPLES

So the output of the whole program is Fruit followed by a new line.

The screenshot of the code along with the output is attached.

You might be interested in
What advantage do ExpressCard modules and U.S.B adapters offer over expansion cards?
sladkih [1.3K]
The advantage does of ExpressCard modules and U.S.B adapters offer over expansion cards is that it can connect a variety of devices to a computer. The technical standard of ExpressCard specifies the design of slots built into the computer and of expansion of cards to insert in the slots including the mobile broadband modems. It is sometimes connectors for externals devices such as flash drives, USB connectors and other ports that need to connect to the computer.
4 0
3 years ago
What electronic appliances at your home / school can be controlled remotely? Name any 4
Paladinen [302]

Answer:

Hi how are you doing today Jasmine

8 0
2 years ago
From the television industry's point of view, which of the following would be the most desirable viewer?
slava [35]
A 50-year-old African American man
4 0
3 years ago
Joe, a user, wants his desktop RAID configured to allow the fastest speed and the most storage capacity. His desktop has three h
kirill115 [55]

Answer:

A. 0

Explanation:

The technician should configure the RAID 0 for Joe.

RAID 0 also referred to as the striped volume or stripe set is configured to allow the fastest speed and the most storage capacity by splitting data evenly across multiple (at least two) disks, without redundancy and parity information.

Also, RAID 0 isn't fault tolerant, as failure of one drive will cause the entire array to fail thereby causing total data loss.

7 0
3 years ago
Kathleen has written this paragraph:
yarga [219]

Answer:

Positive media attention can transform communities in unexpected ways.

Explanation:

According to the given excerpt, it is narrated that Kathleen wrote about a town called Abbston that was recently overwhelmed by tourists as a result of the news article by a TV travel editor who wrote about the town.

Therefore, the best concluding sentence for the paragraph would be that positive media attention can transform communities in unexpected ways.

8 0
3 years ago
Read 2 more answers
Other questions:
  • What are the arguments for writing efficient programs even though hardware is relatively inexpensive?
    10·1 answer
  • (In C prog.) What is the difference between scanf, getche and getchar?
    12·1 answer
  • Classes cannot:
    10·1 answer
  • laire writes a letter to her grandmother, in which she describes an amusement park she visited last week. She adds pictures of t
    11·1 answer
  • Its a zoom call
    7·1 answer
  • 1) List at least five smaller behaviors you could break the complex behavior "brushing my teeth" into.
    14·2 answers
  • Which type of financial institution typically has membership requirements?
    9·2 answers
  • Select the correct answer.
    15·1 answer
  • In this image, which feature did we most likely use to quickly change the background, fonts, and layout?
    6·1 answer
  • Help PLEASE ILL MARK as brainlest
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!