Question

In: Computer Science

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

Print either "Fruit", "Drink", or "Unknown" (followed by a newline) depending on the value of userItem. Print "Unknown" (followed 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:

Fruit



Sample 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.)

Solutions

Expert Solution

Program Code portion screen shot:

Progam Code Screen Shot:

Sample Output:

Program code portion to copy:

// Declare the main function

int main()

{

       // Declare the enum of fruits

       enum GroceryItem { GR_APPLES, GR_BANANAS, GR_JUICE, GR_WATER };

       // Declare the Grocery Item

       GroceryItem userItem = GR_APPLES;

       switch (userItem)

       {

       // Declare the case of GR Apples

       case GR_APPLES:

       // Declare the case of GR BANANAS

       case GR_BANANAS: cout << "Fruit";

              cout << endl;

              break;

       // Declare the case of GR Juice

       case GR_JUICE:

       // Declare the case of GR_WATER

       case GR_WATER: cout << "Drink";

              cout << endl;

              break;

       // Declre the by default case

       default: cout << "Unknown";

              cout << endl;

              break;

       }

       // system pause to hold the screen

       system("pause");

       // return the element.

       return 0;

}

Program code to copy:

// Header file require only in Viual studio

#include "stdafx.h"

//Required header files.

//Include the iostream header file for

//input oputput operations.

#include

// Define the name space of the program

using namespace std;

// Declare the main function

int main()

{

       // Declare the enum of fruits

       enum GroceryItem { GR_APPLES, GR_BANANAS, GR_JUICE, GR_WATER };

       // Declare the Grocery Item

       GroceryItem userItem = GR_APPLES;

       switch (userItem)

       {

       // Declare the case of GR Apples

       case GR_APPLES:

       // Declare the case of GR BANANAS

       case GR_BANANAS: cout << "Fruit";

              cout << endl;

              break;

       // Declare the case of GR Juice

       case GR_JUICE:

       // Declare the case of GR_WATER

       case GR_WATER: cout << "Drink";

              cout << endl;

              break;

       // Declre the by default case

       default: cout << "Unknown";

              cout << endl;

              break;

       }

       // system pause to hold the screen

       system("pause");

       // return the element.

       return 0;

}


Related Solutions

Print either "Fruit", "Drink", or "Unknown" (followed by a newline) depending on the value of userItem....
Print either "Fruit", "Drink", or "Unknown" (followed by a newline) depending on the value of userItem. Print "Unknown" (followed 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 <stdio.h> int main(void) { enum GroceryItem {GR_APPLES, GR_BANANAS, GR_JUICE, GR_WATER}; enum GroceryItem userItem = GR_APPLES; /* Your solution goes here */ return 0; } USE C PLEASE
Print either "Fruit", "Drink", or "Unknown" (followed by anewline) depending on the value of userItem....
Print either "Fruit", "Drink", or "Unknown" (followed by a newline) depending on the value of userItem. Print "Unknown" (followed 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 FOR JAVA import java.util.Scanner; public class GrocerySorter { public enum GroceryItem {GR_APPLES, GR_BANANAS, GR_JUICE, GR_WATER}; public static void main (String [] args) { GroceryItem userItem = GroceryItem.GR_APPLES; /* Your solution goes here */ return; }...
Real Fruit Juice: A 32 ounce can of a popular fruit drink claims to contain 20%...
Real Fruit Juice: A 32 ounce can of a popular fruit drink claims to contain 20% real fruit juice. Since this is a 32 ounce can, they are actually claiming that the can contains 6.4 ounces of real fruit juice. The consumer protection agency samples 44 such cans of this fruit drink. Of these, the mean volume of fruit juice is 6.33 with standard deviation of 0.19. Test the claim that the mean amount of real fruit juice in all...
Real Fruit Juice (Raw Data, Software Required): A 32 ounce can of a popular fruit drink...
Real Fruit Juice (Raw Data, Software Required): A 32 ounce can of a popular fruit drink claims to contain 20% real fruit juice. Since this is a 32 ounce can, they are actually claiming that the can contains 6.4 ounces of real fruit juice. The consumer protection agency samples 30 such cans of this fruit drink. The amount of real fruit juice in each can is given in the table below. Test the claim that the mean amount of real...
Real Fruit Juice (Raw Data, Software Required): A 32 ounce can of a popular fruit drink...
Real Fruit Juice (Raw Data, Software Required): A 32 ounce can of a popular fruit drink claims to contain 20% real fruit juice. Since this is a 32 ounce can, they are actually claiming that the can contains 6.4 ounces of real fruit juice. The consumer protection agency samples 30 such cans of this fruit drink. The amount of real fruit juice in each can is given in the table below. Test the claim that the mean amount of real...
Real Fruit Juice (Raw Data, Software Required): A 32 ounce can of a popular fruit drink...
Real Fruit Juice (Raw Data, Software Required): A 32 ounce can of a popular fruit drink claims to contain 20% real fruit juice. Since this is a 32 ounce can, they are actually claiming that the can contains 6.4 ounces of real fruit juice. The consumer protection agency samples 30 such cans of this fruit drink. The amount of real fruit juice in each can is given in the table below. Test the claim that the mean amount of real...
Real Fruit Juice (Raw Data, Software Required): A 32 ounce can of a popular fruit drink...
Real Fruit Juice (Raw Data, Software Required): A 32 ounce can of a popular fruit drink claims to contain 20% real fruit juice. Since this is a 32 ounce can, they are actually claiming that the can contains 6.4 ounces of real fruit juice. The consumer protection agency samples 30 such cans of this fruit drink. The amount of real fruit juice in each can is given in the table below. Test the claim that the mean amount of real...
The cost of unleaded gasoline in the Bay Area once followed an unknown distribution with a...
The cost of unleaded gasoline in the Bay Area once followed an unknown distribution with a mean of $3.32 and a standard deviation of $0.12. If 37 gas stations are randomly sampled, what is the probability that that the average price of the 37 gas stations is between $3.32 and $3.35? What distribution will you use to calculate this probability? N(3.32, __________) List the zz-scores needed to calculate the result. If there is more than one zz-score, separate the values...
Take an unknown number of integers as input and print the second smallest number. If there...
Take an unknown number of integers as input and print the second smallest number. If there is no second smallest number in the sequence the program should print an error message and quit. Write a function that takes a vector as argument and that returns an int containing the second smallest number. If no such number exists, the function should throw an exception that in turn is caught in main. Your program should compute its answer with a complexity no...
Neurotransmitters within the ANS can either be excitatory or inhibitory depending on where they are located...
Neurotransmitters within the ANS can either be excitatory or inhibitory depending on where they are located as well as what receptor binds them. Give an example of how the parasympathetic sympathetic divisions can sometimes be inhibitory or excitatory. Include the effectors and receptors.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT