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
What internal commands can we use when in interactive mode? can we use CLS and CD?
krok68 [10]
The cd command, also known as chdir (change directory), is a command-line shell command used to change the current working directory in various operating systems. It can be used in shell scripts and batch files.
3 0
3 years ago
What is the term that is used to describe a computer system that could store literary documents, link them according to logical
madreJ [45]

Answer:

hypertext

Explanation:

Based on the information provided within the question it can be said that the type of computer system function being described is known as hypertext. This displays text to the computer display that references other literary documents for immediate access to them. These are documents with a specific relation to the text that is being displayed and also allows readers to comment and annotate what they read on the documents.

5 0
3 years ago
So this is what i use to code and all of that
givi [52]

Answer: yeah!

Explanation:

Have a good day!

5 0
3 years ago
You need to view the contents of /var/log/auth.log to get information about the users that have been logging on to the system. T
leva [86]

Answer:

more /var/log/auth.log

less /var/log/auth.log

Explanation:

The commands that can be used to view the content of the auth.log file page by page are:

more /var/log/auth.log

less /var/log/auth.log

5 0
3 years ago
Which button is used to set up the pen color?
Mrac [35]
C. custom slideshow because this is where you can customise everything you do eg. pen colour, don't etc.
5 0
4 years ago
Read 2 more answers
Other questions:
  • List and describe the three types of cloud models described by Microsoft.
    9·1 answer
  • Which principle of animation deals with imparting a unique identity to the animated character?
    5·1 answer
  • What is institutional advertising focused on promoting?
    8·1 answer
  • You can use______ in order to allow the user to browse and find a file at run time.
    15·1 answer
  • How do myths impact today’s society.(A
    14·2 answers
  • Assume that the demand curve for DVD players shifts to the left and the supply curve for DVD players shifts to the right, but th
    6·1 answer
  • Why is it so important to adhere to principles that have been put forth by reputable organizations to ensure that you are mainta
    10·1 answer
  • Write a program that takes a first name as the input, and outputs a welcome message to that name.
    9·1 answer
  • Jade has to create a workbook for storing information of students participating in the annual state-level sports competition. Th
    5·1 answer
  • A related database stores data in the form of______
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!