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
zaharov [31]
3 years ago
5

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:
Computers and Technology
2 answers:
kenny6666 [7]3 years ago
5 0
According to your syntax, I am pretty sure that this one is C++ question. I think that your solution looks like this:
So if useritem is gr_apples, output should be "Fruit".
int main() {   enum GroceryItem {GR_APPLES, GR_BANANAS, GR_JUICE, GR_WATER};
   GroceryItem userItem = GR_APPLES; if((userItem == GR_APPLES) || (userItem == GR_BANANAS)){ cout << "Fruit"; } else if((userItem == GR_JUICE) || (userItem == GR_WATER)){ cout << "Drink"; } else{ cout << "Unknown"; }
cout << endl;   return 0;}
BartSMP [9]3 years ago
5 0

The given problem can be solved using loops. Compare the user items with given grocery items and print the result whether it is "Fruit", "Drink", or "Unknown".  Here,  enum data structure is used to store the grocery items and if- else loop is used to categorize the grocery items.

Further Explanation:

Code:

The complete C++ code for the given problem is as shown below:

#include <iostream>

using namespace std;

/*Print either "Fruit", "Drink", or "Unknown" depending on the inputs*/

int main() {

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

GroceryItem userItem = GR_APPLES;

/* The solution goes here  */

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

cout << "Fruit";

}

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

cout << "Drink";

}

else{

cout << "Unknown";

}

cout << endl;

return 0;

}

Output:

Run the program, the output will be look like as below:

Testing with userItem = GR_APPLES

Your output: Fruit

Testing with userItem = GR_JUICE

Your output: Drink

Testing with userItem = 5

Your output: Unknown

Learn more:

1. A company that allows you to license software monthly to use online is an example of ? brainly.com/question/10410011  

2. How does coding work on computers?  brainly.com/question/2257971 

Answer details:

Grade: College Engineering

Subject: Computer Science

Chapter: C++  Programming

Keyword:

C++, input, output, programming, statements,  loops, if, else, statements, newline, useritem, drink, fruits, return 0

You might be interested in
a computer technician performed a number of actions to correct a problem. some actions did not solve the problem, but eventually
padilas [110]

The technician should document all that was done to try to solve the problem. A detailed record is a good practice to find solutions.

A detailed record documenting all steps by which a problem was solved is a good practice for technicians.

This documented record will help the computer technician to find the cause the next time.

Clear, accurate records support decision-making and solving problems in any job and profession.

Learn more about detailed records here:

brainly.com/question/6284693

4 0
2 years ago
Research 3 distributions that utilize the big data file systems approaches, and summarize the characteristics and provided funct
OlgaM077 [116]

Answer:

Explanation:

1: The three most popular data systems that make use of Big Data file systems approach are:

The HDFS (Hadoop Distributed File System), Apache Spark, and Quantcast File System(QFS).

HDFS is the most popular among these and it makes use of the MapReduce algorithm to perform the data management tasks. It can highly tolerate faults and can run on low-cost hardware. It was written in Java and it is an open-source software.

Apache Spark makes use of Resilient Distributed Data (RDD) protocol. It is much faster and lighter than the HDFS and it can be programmed using a variety of languages such as Java, Scala, Python, etc. Its main advantage over HDFS is that it is highly scalable.

While QFS was developed as an alternative to the HDFS and it is also highly fault-tolerant and with space efficient. It makes use of the Reed-Solomon Error Correction technique to perform the task of data management.

2: The NewSQL databases were developed as a solution to the scalability challenges of the monolithic SQL databases. They were designed to allow multiple nodes in the context of an SQL database without affecting the replication architecture. It worked really well during the starting years of the cloud technology. Some of the databases that make use of New SQL technology are Vitess, Citus, etc.

Vitess was developed as an automatic sharding solution to the MySQL. Every MySQL instance acts as a shard of the overall database and each of these instances uses standard MySQL master-slave replication to ensure higher availability.

While, Citus is a PostgreSQL equivalent of the Vitess. It ensures transparent sharding due to which it accounts for horizontal write scalability to PostgreSQL deployments.

NoSQL database technology was developed to provide a mechanism for the storage and retrieval of data that is modeled in a way other than the tabular relations used in the traditional databases (RDBMS). The most popular database that makes use of the NoSQL technology is MongoDB. It functions as a cross-platform document-oriented database. It is known for its ability to provide high availability of replica sets. A replica set is nothing but a bundle of two or more copies of the data

3 0
3 years ago
The domain name system ________. Question 2 options: A) is a way to find a host's IP addresses if your computer only knows the h
ra1l [238]

Answer:

C) both a and b

Explanation:

13) The domain name system ________.

A) is a way to find a host's IP addresses if your computer only knows the host's host name

B) is a general naming system for the Internet

C) both A and B

D) neither A nor B

8 0
2 years ago
Which line in the following code contain an error
Burka [1]
Please attach a photo
4 0
4 years ago
Is there anybody who knows eris quirk but me- i feel lonely rn ;-;
Nutka1998 [239]

Answer:i do Eri's Quirk allows her to rewind an individual's body to a previous state. She has shown the ability to rewind someone's body to a point before they existed, which she accidentally did to her father.

3 0
3 years ago
Read 2 more answers
Other questions:
  • 3.14 LAB: Simple statistics for Python
    7·1 answer
  • Which one of the following is an example of hacktivism according to you and why?
    11·1 answer
  • Aapke question about computer keyboard​
    5·1 answer
  • What is the role of the federal government in regulating the media and the internet?
    6·2 answers
  • Please tell me the answer
    5·1 answer
  • Code works, need help writing header file.
    8·1 answer
  • 7.2 need help plzs 15 points
    13·1 answer
  • In this exercise, you will get some practice with the __add__ method by implementing it for a class called ContactBook. This cla
    12·1 answer
  • If I am working in a document and wish to follow a hyperlink, what should I do?
    7·1 answer
  • Role of User Defined Iprms for creation of paten
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!