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]
3 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]3 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
The 'client area' of a window is the area used to display the contents of the window (thus a title bar or border would lie outsi
Lady_Fox [76]

Answer:

<u>Window.java</u>

  1. public class Window {
  2.    int width;
  3.    int height;
  4.    public Window(int width, int height){
  5.        this.width = width;
  6.        this.height = height;
  7.    }
  8.    public int getWidth(){
  9.        return width;
  10.    }
  11.    public int getHeight(){
  12.        return height;
  13.    }
  14.    public int getClientAreaHeight(){
  15.        return getHeight();
  16.    }
  17. }

<u>Main.java</u>

  1. public class Main {
  2.    public static void main (String [] args) {
  3.        Window win1 = new Window(12, 15);
  4.        System.out.println(win1.getClientAreaHeight());
  5.    }
  6. }

Explanation:

<u>Window.java</u>

There is a Window class with two int type attributes, width and height (Line 1 - 3).

The constructor of this class will take two inputs, width and height and set these input to its attributes (Line 5 - 8). There are two methods getWidth and getHeight which will return the value of attributes width and height, respectively (Line 10 - 16).

The required new method getClientAreaHeight is defined in line 18 -20. This method will call the getHeight method to return the height value of the window (Line 19).

<u>Main.java</u>

We test the Window class by creating one Window instance and call the getClientAreaHeight method and print the return output (Line 1 -6).

We shall see 15 is printed.

4 0
3 years ago
For each policy statement, select the best control to ensure Ken 7 Windows Limited fulfills the stated requirements and also pro
elena-14-01-66 [18.8K]

Answer:

1. Option (a) is the correct answer. "Place a firewall between the Internet  and your Web server".

2.  Option (e) is the correct answer. "Require encryption for all traffic flowing into and out from the Ken 7 Windows environment".

3. Option (d) is the correct answer. "Implement Kerberos authentication for all internal servers".

4. The correct answer is option (g) "Require all personnel attend a lunch and learn session on updated network security policies".

5. Option (c) is the correct answer. "Enforce password complexity".

Explanation:

1. Users who tried to use ken 7 network resources for social media access will not be enable to do so.

2. Encryption for inflow and outflow of traffic from Ken 7 windows environment will monitor any personal devices which is connected to Ken 7 windows network.

3. The implementation of Kerberos authentication will deny anonymous users access to protected resources in Ken 7 infrastructure.

4.All personnel will be taught the network policies  to avoid sending report to unsecured printers.

5.  The more complex passwords are, the more secured the server will be. A complex password should be enforce for network security.

8 0
3 years ago
Design a hierarchy of classes, where the Media superclass has the artistName and the mediaName as the common attributes. Create
zaharov [31]

Answer:

See attached file.

Explanation:

See attached file for detailed code.

Download txt
7 0
3 years ago
.Write a C++ program that displays your name and address (if you value your privacy, a fictitious name and address).
olga_2 [115]

Answer:

#include <iostream>

using namespace std;

int main() {

   cout<<"My name is Rajat Sharma"<<endl<<"My address is Flat no=23 GH=5 Paschim Vihar New Delhi 110087 India"<<endl;

return 0;

}

Explanation:

The program is written in C++ language.In the program I have used cout to print my name and the address.First the name will be printed then the address in the new line endl is used for new line.To print any sentence just put them in double quotes.The same sentence in the program will be printed on the screen.

5 0
3 years ago
How to convert 23.125 to binary (Hex) using the double - precision representation
Svet_ta [14]

Answer:-

(10111.001)₂

Explanation:

To convert a decimal number to a binary number we have to constantly divide the decimal number by 2 till the decimal number becomes zero and the binary number is writing the remainders in reverse order of obtaining them on each division.

Hence the binary number is 10111.001

To convert binary to hexa decimal we to make a group 4 binary bits starting from the decimal and moving outwards if the last group is not of 4 then add respective 0's and write the corresponding hexa decimal number.

<u>0001</u>  <u>0111</u> . <u>0010</u>

   1        7         2

Hence the hexadecimal number is 17.2

6 0
2 years ago
Other questions:
  • When you enter search keywords in the search box of file explorer and the onedrive option is selected?
    15·2 answers
  • Households pay taxes to the government and receive public services. Which of the following is a public service?
    8·1 answer
  • NEED HELP ASAP! BRAINLIEST AND 20 PTS TO CORRECT ANSWER!
    14·1 answer
  • A JOB LEADS SOURCE LIST is used to help record all of the job leads you can find. It includes contact information and a plan for
    8·1 answer
  • Which of the following helps create a positive community?
    11·1 answer
  • What feature should be used before a document is printed
    8·1 answer
  • Manfred wants to include the equation for the area of a circle in his presentation. Which option should he choose?
    11·2 answers
  • Submit your business presentation that clearly compares and contrasts three different cell phone service plans..
    14·2 answers
  • How do you copy a file​
    9·1 answer
  • What does a theme contain?
    14·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!