Question

In: Other

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

Solutions

Expert Solution

Executable code:

C code:

#include

#include

int main()

{

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

GroceryItem userItem = GR_APPLES;

//switching into the user Input

switch(userItem)

{

//switch cases for fruits

case GR_APPLES:

case GR_BANANAS:

printf("Fruit\n");

break;

//switch cases for drinks

case GR_JUICE:

case GR_WATER:

printf("Drink\n");

break;

//default case called unknown

default : printf("Unknown\n");

break;

}

system("pause");

return 0;

}


Related Solutions

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...
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; }...
Print "Censored" if userInput contains the word "darn", else print userInput. End with newline. Note: These...
Print "Censored" if userInput contains the word "darn", else print userInput. End with newline. Note: These activities may test code with different test values. This activity will perform three tests, with userInput of "That darn cat.", then with "Dang, that was scary!", then with "I'm darning your socks.". See "How to Use zyBooks". . Also note: If the submitted code has an out-of-range access, the system will stop running the code after a few seconds, and report "Program end never...
Print "Censored" if userInput contains the word "darn", else print userInput. End with newline. Ex: If...
Print "Censored" if userInput contains the word "darn", else print userInput. End with newline. Ex: If userInput is "That darn cat.", then output is: Censored Ex: If userInput is "Dang, that was scary!", then output is: Dang, that was scary! Note: If the submitted code has an out-of-range access, the system will stop running the code after a few seconds, and report "Program end never reached." The system doesn't print the test case that caused the reported message. #include <iostream>...
Print "Censored" if userInput contains "darn", else print iserInput. End with newline. Ex: If userInput is...
Print "Censored" if userInput contains "darn", else print iserInput. End with newline. Ex: If userInput is "That darn cat", then output is:
(Java Zybooks) Print "Censored" if userInput contains the word "darn", else print userInput. End with newline....
(Java Zybooks) Print "Censored" if userInput contains the word "darn", else print userInput. End with newline. Ex: If userInput is "That darn cat.", then output is: Censored Ex: If userInput is "Dang, that was scary!", then output is: Dang, that was scary! Note: If the submitted code has an out-of-range access, the system will stop running the code after a few seconds, and report "Program end never reached." The system doesn't print the test case that caused the reported message....
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...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT