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]
4 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]4 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
Write a C program that stores the number 123.45 in the variable alpha, 98.76 in the variable beta, and 76.67 in the variable gam
Anon25 [30]

Answer:

C

Explanation:

the answer

8 0
2 years ago
A graphic on-screen image representing an object or an idea is called a(n) A. menu. B. image. C. graphic. D. icon.
kap26 [50]
It's called D. icon
We often see these icons on our desktop page as soon as we logged on to our personal computer.
The icon on the destkop will acted as a short-cut that will opened up and connected us with the program simply by clicking the icon.
8 0
4 years ago
Read 2 more answers
give an example of both a negative and positive coping mechanism you could use to deal with this stress?
Andru [333]

Answer:

Negative coping mechanism deals with Substance dependence, abuse, and use; anger, violent mentality, risky mentality, dangerous mentality, reminders such as trauma, etc.

The positive coping mechanism can be like an attempt to transform or change the issue into something other than that. As an example, it can be like converting a stressful situation into a positive situation.

Explanation:

Please check the answer section.

4 0
3 years ago
Which of these types of weathering requires the presence of water?
lukranit [14]
A) Carbonation requires the presence of water.
6 0
3 years ago
Read 2 more answers
Suppose a group consists of 5 students. Three students are selected at random to do a presentation. How many different sets of p
Klio2033 [76]

Answer:

The number of presentation groups of 3 students that can be selected from a group of 5 students equals 10.

Explanation:

The number of different presenters equals the no of possible combinations of 3 students from a pool of 5 students.

Thus the number of possible combinations equals

\binom{5}{3}=\frac{5!}{(5-3)!\times 3!}=10

6 0
4 years ago
Other questions:
  • Possible consequences for plagiarism, listed in CAVA's Academic Integrity Policy, may include:
    9·1 answer
  • What education and training is required to be an applications software engineer?
    9·1 answer
  • Which of these sites would need additional investigation to check for reliability?
    8·2 answers
  • if an individual inserts a thumb drive containing classified information on a computer in the office that is not part of the cla
    9·1 answer
  • What saw do you use to cut wood in design and technology
    7·1 answer
  • Does anyone play fortnite i want to be gifted vbucks please my epic is Springtrap_locks thx means a lot to me
    8·1 answer
  • How to convert a .enw file into a .pdf without downloading any applications? (If I have to, then I will. Just please tell me.)
    14·2 answers
  • Write a single statement that assigns avg_sales with the average of num_sales1, num_sales2, and num_sales3.
    15·1 answer
  • What is the most common type of storage device for transferring files from one computer to another?
    10·1 answer
  • If two devices simultaneously transmit data on an Ethernet network and a collision occurs, what does each station do in an attem
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!