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
sleet_krkn [62]
3 years ago
13

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 is GR_APPLES, output should be:Fruit#include int main(void) {enum GroceryItem {GR_APPLES, GR_BANANAS, GR_JUICE, GR_WATER};enum GroceryItem userItem = GR_APPLES;/* Your solution goes here */return 0;}

Computers and Technology
1 answer:
Sloan [31]3 years ago
5 0

Answer:

Here is the complete code

#include <iostream>  //for input output functions

using namespace std;   //to identify objects like cin cout

int main() {  //start of main() function body

  enum GroceryItem {GR_APPLES, GR_BANANAS, GR_JUICE, GR_WATER};  //enum is used to assign names to constant

  GroceryItem userItem = GR_APPLES;  

//value of userItem is set to GR_APPLES

  /* Your solution goes here  */

//if the userItem is equal to GR_APPLES or GR_BANANAS

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

 cout << "Fruit";  } //display Fruit if above if condition is true

//if the value of userItem is equal to GR_JUICE or GR_WATER

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

 cout << "Drink";  } //display Drink if the above if condition is true

else{  //if none of the above if conditions is true then print Unknown

 cout << "Unknown";  }  

cout << endl;

  return 0;  }

Explanation:

The output of the program is Fruit because the value of userItem is set to GR_APPLES and according to the if statement if the userItem is equal to GR_APPLES than "Fruit" will be displayed on the screen as output.

The program along with its output is attached as a screen shot.

You might be interested in
Which C99 function can be used to convert a string to a double?
nordsb [41]

Answer:

atof

Explanation:

atof function is used to convert a string to a double.

It takes a single parameter of type const char * and returns a double value.

The function signature is: double atof (const char* str);

In order to use this function in the code, you need to include the header file <stdlib.h>

For example:

#include <stdio.h>

#include <stdlib.h>  

int main()

{

   char str[5] = "0.01";

   double d = atof(str);

   printf("Value = %f\n", d);

   return 0;

}

5 0
3 years ago
The open items on your computer are displayed here.
koban [17]
The GUI or Graphical <u /><u></u><em />User Interface.
7 0
2 years ago
One of the main responsibilities employers have under OSHA is to:
poizon [28]
What dose osha means please
7 0
3 years ago
Read 2 more answers
These operating systems were referred to as command-based.
Doss [256]

{\underline{\boxed{\bf{MS - DOS \:  and \:  UNIX}}}}

3 0
2 years ago
Read 2 more answers
Which of the following are incorrect? Group of answer choices An interface can contain constructors. You may declare a final abs
spin [16.1K]

Answer:

Explanation:

1. The answer is No, interface cannot have constructors. ... In order to call any method we need an object since there is no need to have object of interface, there is no need of having constructor in interface (Constructor is being called during creation of object).

2.A final class is considered complete and can not be subclassed (It's methods can not be overridden ). In case of abstract class, we have to proved implementation to abstract methods in subclasses. A final class can not have abstract methods and an abstract class can not be declared final.

3.private constructors are acceptable, however the class should be marked final instead, as doing so means the class is to be extended.

4.Yes! Abstract classes can have constructors! Yes, when we define a class to be an Abstract Class it cannot be instantiated(i.e an object cannot be created) but that does not mean an Abstract class cannot have a constructor. Each abstract class must have a concrete subclass which will implement the abstract methods of that abstract class.

6 0
3 years ago
Read 2 more answers
Other questions:
  • What security protocol originally came with 802.11 equipment?
    11·1 answer
  • Because public key encryption requires the use of two different keys, it is also known as _____ encryption
    13·1 answer
  • Derek is working at the help desk when he receives a call from a client about an issue with the company's email. The customer is
    9·1 answer
  • To the following is not a network connection LAM MAN SAN WAN
    9·1 answer
  • The term ____ describes primary storage devices that are implemented as microchips, can read and write with equal speed, and can
    8·1 answer
  • 14. Which of the following statements is true? A. The most secure email message authenticity and confidentiality isprovided by s
    11·1 answer
  • How does netbios identify a computer system on the network?
    13·1 answer
  • What is the median of 6, 16, 9, 20, 45, 30, and 32?<br> A. 9<br> B. 16<br> C. 20<br> D. 22
    7·1 answer
  • What are you win your good at tech
    7·2 answers
  • There are many potential risks associated with the internet. what do we call the distribution and access of illegal copies of di
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!