Assume that an int variable age has been declared and already given a value. Assume further that the user has just been presented with the following menu: S: hangar steak, red potatoes, asparagus T: whole trout, long rice, brussel sprouts B: cheddar cheeseburger, steak fries, cole slaw (Yes, this menu really IS a menu!) Write some code that reads the String (S or T or B) that the user types in into a String variable choice that has already been declared and prints out a recommended accompanying drink as follows: if the value of age is 21 or lower, the recommendation is "vegetable juice" for steak, "cranberry juice" for trout, and "soda" for the burger. Otherwise, the recommendations are "cabernet", "chardonnay", and "IPA" for steak, trout, and burger respectively. Regardless of the value of age, your code should print "invalid menu selection" if the character read into choice was not S or T or B. ASSUME the availability of a variable, stdin, that references a Scanner object associated with standard input.

Answers

Answer 1
Answer:

Answer:

Hi!

The method in Java:

public void chooseMenuAndDrink(int age) {

     String menu;

     Scanner stdin = new Scanner(System.in);

     menu = stdin.next().charAt(0); //read the char and save the value on menu.

     

     if ( menu.equals("S") ) {  // if menu is S

           if(age > 21) { // and age > 21

          System.out.println("cabernet");  // prints cabernet

          } else { System.out.println("vegetable juice"); } // else prints vegetable juice

      }

      if ( menu.equals("T") ) {

           if(age > 21) {

         System.out.println("chardonnay");

     } else { System.out.println("cranberry juice"); }

  }

           if ( menu.equals("B") ) {

           if(age > 21) {

            System.out.println("IPA");

     } else { System.out.println("soda"); }

  }      

  if (!menu.equals("B") & !menu.equals("T") & !menu.equals("S")) { // if menu is not B, T or S

          System.out.println("invalid menu selection"); // prints invalid menu selection

     }

}


Related Questions

What is an image that you can apply to another image to add detail and texture?
What would you do if a friend or family member asked to borrow money? (15 points)write a paragraph
Most email clients contain a ____ that allows the user to read an email message without actually opening it
Assignment: Earth’s Surface Exploration
Identify the components of documents merging

Which leader of the Jamestown colony am I?When I arrived in Jamestown in 1610, only sixty-five settlers were still alive; desperately, they wanted to give up and return to England. I however convinced them to stay after my three supply ships arrived with aid. I was able to restore Jamestown to prosperity with the building of new communities and by putting an end to starvation problems.
John Rolfe
John Smith
Lord Delaware
Nathaniel Bacon
William Byrd II

Answers

I am not completely sure, but I believe that the leader of the Jamestown colony described in this paragraph is John Rolfe.

verified***

Lord Delaware

Sailing in March 1610 with three ships, 150 settlers, and supplies, he arrived at Jamestown on June 10, in time to intercept the colonists who had embarked for England and were abandoning the enterprise.

Stress results from _______. A. Outside stimulus b. Internal stimulus c. Outside calm d. Internal calm

Answers

Stress results from outside stimuli. Option A is correct.

What is cortisol?

Cortisol has been identified as a stress-inducing hormone in studies of hormones in the human body.

Cushing syndrome is a condition characterized by elevated cortisol levels. This disorder is caused by your body producing too much cortisol.

Similar symptoms can occur after large doses of corticosteroids, thus this should be cleared out before testing for crushing syndrome. Stimuli from the outside cause stress.

Hence option A is correct.

To learn more about cortisol refer to the link

brainly.com/question/16288547

#SPJ2

A. outside stimulus

This is a broad category of applications and technologies for gathering, storing, analyzing, and providing access to data to help enterprise users make better business decisions.a. best practice
b. data mart
c. business information warehouse
d. business intelligence
e. business warehouse

Answers

Answer:

Business intelligence.

Explanation:

That concept that applies to that of the selection, incorporation, evaluation, and analysis of companies or business information systems, software, and behaviors. It is direct at promoting good business decision-making.

This is a wide concept of software and technology to capture, store, analyze, and to provide information access to support users make far better strategic decisions.

What is the motion of a wave described as?

Answers

The motion of a wave described as the transfer of energy and momentum from one point of the medium to another.

Wave motion is defined as the exchange of energy and momentum between two points in a medium without any real exchange of matter between the sites. In other words, it is the repeated vibrating of the particles about their mean positions that causes disturbances to propagate through a medium. The wave function is the name given to the function that waves use to cause disturbances as a function of time. In the case of string, it might be the movement of particles, and in the case of sound waves, it might be a change in pressure or density.

Without actually moving substance between the two sites, wave motion is the transfer of energy and momentum from one point of the medium to another.

Therefore, the motion of a wave described as the transfer of energy and momentum from one point of the medium to another.

Learn more about the motion of a wave here:

brainly.com/question/12512349.

#SPJ6

The motion of a wave is described as wave motion.

Which database tool is best for simple flat files that involve calculations?

Answers

The database tool Spreadsheet software is best for simple flat files that involve calculations.
The Spreadsheet software is a computer software that performs general computation tasks using spatial relationships.
Excel is example of spreadsheet software. It organizes, stores and analyzes data in tabular form.

About 15 percent of American households have access to the media. TRUE or FALSE

Answers

Answer:

False!

Explanation: took the quiz and it was right