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
IceJOKER [234]
3 years ago
15

Assume that an int variable age has been declared and already given a value. Assume further that the user has just been presente

d 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.
Computers and Technology
1 answer:
ElenaW [278]3 years ago
6 0

Answer:

Hi!

The method in Java:

public void chooseMenuAndDrink(int age) {

     String menu;

     Scanner stdin = new Scanner(System.in);

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

     

     if ( menu.equals("S") ) {  <em>// if menu is S</em>

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

          System.out.println("cabernet");  <em>// prints cabernet</em>

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

      }

      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")) { <em>// if menu is not B, T or S</em>

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

     }

}

You might be interested in
Consider a system that uses a 32-bit unique salt where users have a 4-digit number as a password (e.g. 6813). Eve wants to crack
Alenkasestr [34]

Answer:

18000 seconds or 300 minutes.

Explanation:

In the example given in the question, it is stated that the system uses 32-bit unique salt which is equal to 4 bytes where every digit takes up 1 byte thus forming the 4 digit passwords.

Considering that the passwords are 4 digits, starting from 1000 and up to 9999, there are 9000 possible password combinations.

If Eve has to go through the whole range of possible password combinations and it takes her 1 second to guess 1 password. Then in the worst case scenario, it would take her 18000 seconds or 300 minutes to crack both accounts, assuming that it is possible for them to use the same passwords.

I hope this answer helps.

6 0
3 years ago
Read 2 more answers
Suppose you are consulting for a bank that's concerned about fraud detection, and they come to you with the following problem. T
iren [92.7K]

Answer:

Explanation:

( n cards are there initially )

we pick out the first card in random it takes n-1 comparisons to figure out

its Equivalence card - n-1 steps

Two cards have been eliminated ( this leaves us with 2 and n-2 cards)

we pick out the 2nd card in random it takes n-3 comparisons to figure out

its Equivalence card - n-3 steps

we continue to do this.. till all cards are exhausted ( leaves us with 2

and n-4 cards again)

the last comparison will

have

- n-(n-3)

the sum of all these steps - (n-1) + (n-3) + (n-5) + .........+

(n-(n-3))

if you draw this in the form of a tree.

n - n

2

n-2 - n

2

n-4 - n-2

2

n-6 - n-4

2

n-8 - n- 6

the height of the tree will be log n , sum @ each level is at most n

8 0
3 years ago
What are the three general methods for delivering content from a server to a client across a network
Tju [1.3M]

Answer:

Answered below.

Explanation:

The three general methods consist of unicasting, broadcasting and multicasting.

Casting implies the transfer of data from one computer (sender) to another (recipient).

Unicasting is the transfer of data from a single sender to a single recipient.

Broadcasting deals with the transfer of data from one sender to many recipients.

Multicasting defines the transfer of data from more than one sender to more than one recipients.

8 0
3 years ago
You are a network administrator. Your company recently approved of employees working from home one day a week and the use of emp
Orlov [11]

Answer:

To establish the BYOD policy is the correct answer to the following question.

Explanation:

<u>Implementation of the BYOD(Bring Your Own Device)</u>:

  1. Firstly, set you objectives and establish it.
  2. Then, you have to decide and tell your employees that what types of devices are only allowed in your organization.
  3. Then, establish your security policies related to the BYOD policy.
  4. Then, give good training by you or by the IT professionals to your employees.
  5. Finally, if the employee are leaving your organization then, you have to remove those employees from the BYOD policy by which they cannot access your company's informations.
8 0
3 years ago
Help me please. i need you help​
Fudgin [204]

Answer:

Can you provide the code

7 0
3 years ago
Other questions:
  • List 3 ways that you can use excel and the features it includes and explain why a spreadsheet is the best choice for this task.
    5·1 answer
  • Which system tool allows you to manage the available space on your hard disk to improve efficiency? A. ScanDisk B. Anti-Virus C.
    10·1 answer
  • Write a program that takes the radius of a sphere (a floating-point number) as input and then outputs the sphere’s: Diameter (2
    7·1 answer
  • While the names for Web addresses, or URLs, are not case-sensitive, the names for files you create for the Web are. 
    11·1 answer
  • What games do you play?<br><br><br> Be sure not to report any answers!
    5·1 answer
  • Who innovated an aeroplane? ​
    5·1 answer
  • Which statements are true? Select 4 options.
    9·1 answer
  • 4. Contoso, Ltd. has a vigorous Office 365 and Azure cloud-service presence.
    8·1 answer
  • Please help me with these questions. Thanks o((&gt;ω&lt; ))o
    12·1 answer
  • The unit we use to measure bending moment is...<br> A kg<br> B N<br> C Nm<br> D MPa
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!