answer.
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]
2 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]2 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
Kelli is unable to find a shape that meets her needs which feature in PowerPoint should she use to create shapes that are comple
sergij07 [2.7K]

In order to customize a shape, Kelli should first add a basic shape and select it. After that, she needs to access the format tab where she can find the option to edit the selected shape. She can modify the selected shape or change it to a free-form according to her needs.

<u>Explanation:</u>

Microsoft PowerPoint provides an easy way for customizing the shapes according to the needs of the user.

Although PowerPoint provides many basic shapes that suit the need of most of the users but in exceptional cases, changes are always welcome. So in order to customize a shape, she should follow the steps which has been explained above.

5 0
2 years ago
Create an application named TestSoccerPlayer that instantiates and displays a SoccerPlayer object. The SoccerPlayer class contai
frutty [35]

Answer:

public class TestSoccerPlayer {

   public static void main(String[] args) {

       SoccerPlayer playerOne = new SoccerPlayer("Rinco",9,16,22);

       System.out.println("The player of the season is "+playerOne.getName()+" His Jessey Number is "+playerOne.getJerseyNum()

       +" In the 2019/2020 season he scored and total of "+playerOne.getGoalsScored()+" and "+

               playerOne.getAssists()+" Asists");

   }

}

See the SoccerPlayer class with the feilds and methods (constructor, getter and setters) in the explanation section

Explanation:

public class SoccerPlayer {

   private String name;

   private int jerseyNum;

   private int goalsScored;

   private int assists;

   public SoccerPlayer(String name, int jerseyNum, int goalsScored, int assists) {

       this.name = name;

       this.jerseyNum = jerseyNum;

       this.goalsScored = goalsScored;

       this.assists = assists;

   }

   public String getName() {

       return name;

   }

   public void setName(String name) {

       this.name = name;

   }

   public int getJerseyNum() {

       return jerseyNum;

   }

   public void setJerseyNum(int jerseyNum) {

       this.jerseyNum = jerseyNum;

   }

   public int getGoalsScored() {

       return goalsScored;

   }

   public void setGoalsScored(int goalsScored) {

       this.goalsScored = goalsScored;

   }

   public int getAssists() {

       return assists;

   }

   public void setAssists(int assists) {

       this.assists = assists;

   }

}

5 0
2 years ago
Why is it important to back up data on a computer before you burn-in test the cpu?
katen-ka-za [31]
A burn-in test is a test which is usually performed on a system or component by running it for a long time in order to bring out any errors or system failures etc. 
While doing it on CPU the data must be backed up as any kind of error or failure may result in the loss of data, at time systems can be repaired to retrieve data but still there is no guarantee, backing up is the best option.
5 0
2 years ago
Define a new object in variable sculptor that has properties "name" storing "Michelangelo"; "artworks" storing "David", "Moses"
Talja [164]

Answer:

       String [] artworks = {"David","Moses","Bacchus"};

       Sculptor sculptor = new Sculptor("Michaelangelo",artworks,

               "March 6, 1475","February 18, 1564");

Explanation:

  • To solve this problem effectively;
  • Create a class (Java is used in this case) with fields for name, artworks(an array of string), bornDate and diedDate.
  • Create a constructor to initialize this fields
  • In a seperate class SculptorTest, within the main method create an array of String artworks and initialize to {"David","Moses","Bacchus"};
  • Create a new object of the class with the line of code given in the answer section.
  • See code for complete class definition below:

<em>public class Sculptor {</em>

<em>    private String name;</em>

<em>    private String [] artworks;</em>

<em>    private String bornDate;</em>

<em>    private String diedDate;</em>

<em>    public Sculptor(String name, String[] artworks, String bornDate, String diedDate) {</em>

<em>        this.name = name;</em>

<em>        this.artworks = artworks;</em>

<em>        this.bornDate = bornDate;</em>

<em>        this.diedDate = diedDate;</em>

<em>    }</em>

<em>}</em>

<em>//Test Class with a main method</em>

<em>class SculptorTest{</em>

<em>    public static void main(String[] args) {</em>

<em>        String [] artworks = {"David","Moses","Bacchus"};</em>

<em>        Sculptor sculptor = new Sculptor("Michaelangelo",artworks,</em>

<em>                "March 6, 1475","February 18, 1564");</em>

<em>    }</em>

<em>}</em>

6 0
2 years ago
Given an int variable k, an int array incompletes that has been declared and initialized, an int variable studentID that has bee
Feliz [49]

Answer:

check the explanation

Explanation:

Variables when it comes to programming are used to store data to be documented and manipulated in a computer program. They can also be used for labeling stored data with a descriptive name and any other needed details, so that the programs can be comprehended more understandably by the reader and ourselves.

to solve the question, we will write this set of codes;

numberOfIncompletes = 0;

for(k = 0; k < incompletes.length; k++)

{

       if(incompletes[k] == studentID)

           numberOfIncompletes++;

}

7 0
2 years ago
Other questions:
  • An administrator wants to create four subnetworks from the network address 192.168.1.0/24. what is the network address and subne
    11·1 answer
  • Choose all items that represent characteristics of a work samples.
    8·2 answers
  • A 2-dimensional 3x3 array of ints, has been created and assigned to tictactoe. Write an expression whose value is true if the el
    10·1 answer
  • The Online Shopping system facilitates the customer to view the products, inquire about the product details, and product availab
    8·1 answer
  • If productCost and productPrice are numeric variables, and productName is a string variable, which of the following statements a
    11·1 answer
  • Define a function ComputeGasVolume that returns the volume of a gas given parameters pressure, temperature, and moles. Use the g
    13·1 answer
  • Write an expression that will cause the following code to print "I am a teenager" if the value of userAge is less than 20. Zyboo
    13·1 answer
  • Summary: Given integer values for red, green, and blue, subtract the gray from each value. Computers represent color by combinin
    11·1 answer
  • Write a method called printRangeOfNumbers that accepts a minimum, maximum numbers as parameters and prints each number from mini
    6·1 answer
  • Rohan is creating a presentation with at least 50 slides. He wants the slides to use a consistent layout and formatting. Which o
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!