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
HACTEHA [7]
10 months ago
14

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.
Instructor Notes:
Hint:

Use .equals for String comparison, e.g.
if (choice.equals("B")) instead of
if (choice == "B") // BAD

You might want to skip this one and do section 3.6 (which covers String comparison) beforehand.
Computers and Technology
1 answer:
Musya8 [376]10 months ago
8 0

Using the knowledge of computational language in C++ it is possible to write a code that assume that an int variable age has been declared and already given a value

<h3>Writting the code:</h3>

<em>#include<stdio.h></em>

<em>#include<conio.h></em>

<em>int main()</em>

<em>{</em>

<em>//variables to rad choice and age</em>

<em>char choice;</em>

<em>int age;</em>

<em>//read age and choice</em>

<em>printf("\tEnter your age: ");</em>

<em>scanf("%d", &age);</em>

<em>//fflush the keyboard buffer before reading choice</em>

<em>fflush(stdin);</em>

<em>printf("\tEnter your choice: ");</em>

<em>scanf("%c", &choice);</em>

<em>//print the invalid message if the choice is otherthan the S,T,B</em>

<em>if(choice!='S' && choice !='T' && choice !='B')</em>

<em>{</em>

<em>printf("Invalid menu choice");</em>

<em>getch();</em>

<em>}</em>

<em>else if (age <22)</em>

<em>{</em>

<em>if (choice =='S')</em>

<em>{</em>

<em>printf("\tvegetable juice");</em>

<em>}</em>

<em>else if (choice =='T')</em>

<em>{</em>

<em>printf("\tcranberry juice");</em>

<em>}</em>

<em>else if (choice == 'B')</em>

<em>{</em>

<em>printf("\tsoda");</em>

<em>}</em>

<em>}</em>

<em>else</em>

<em>{</em>

<em>if (choice == 'S')</em>

<em>{</em>

<em>printf("\tcabernet");</em>

<em>}</em>

<em>else if (choice =='T')</em>

<em>{</em>

<em>printf("\tchardonnay");</em>

<em>}</em>

<em>else if (choice == 'B')</em>

<em>{</em>

<em>printf("\tIPA");</em>

<em>}</em>

<em>}</em>

<em>//pause the console output until user press any key on keyboard</em>

<em>getch();</em>

<em>}</em>

See more about C++ at brainly.com/question/19705654

#SPJ1

You might be interested in
Which of the following has likely attended vocational school?
JulsSmile [24]

C- A graphic designer is the awnser

7 0
3 years ago
The members of the IT department have spent two days debating the best approach to roll out the new software update. After allow
devlian [24]

Answer:

<em>Functional conflict</em>

Explanation:

Functional conflict means<em> encouraging workers to communicate different points of view and address disagreements in a healthy manner that can promote new ideas and new innovations.</em>

This compares with the unstable type of conflict that has no business advantage and only hurts the morale of interaction, productivity and workplace.

4 0
3 years ago
Often, a single source does not contain the data needed to draw a conclusion. It may be necessary to combine data from a variety
nlexa [21]

To measure the pollution of a particular river, one must take the sample of the river and take the sample of pure water, then draw the conclusion, it will tell the amount of pollution in the river water.

<h3>What is pollution?</h3>

Pollution is the mixing of unwanted or harmful things in any substance or compound.

Water pollution is the mixing of toxics and chemicals in water.

Thus, to measure the pollution of a particular river, one must take the sample of the river and take the sample of pure water, then draw the conclusion, it will tell the amount of pollution in the river water.

Learn more about pollution

brainly.com/question/23857736

#SPJ1

6 0
2 years ago
Xbrl taxonomy: is the document format used to produce web pages. is the final product (report. is a classification scheme. is a
frosja888 [35]
The answer to this is "is a classification scheme"..hope that helped
3 0
3 years ago
Assuming that the message variable contains the string "Happy holidays", the statement message.find("days"); returns a. -1b. 10c
katrin [286]

Answer:

Answer is b. 10                

Explanation:

The find() method is used to search the string for a specified value and searches the first occurrence of that value. It returns the position of that specified value. If the value is not found, this method returns -1.

Lets say we have a message variable that contains the string Happy holidays.

message = "Happy holidays"

We use the method find() to find days word from the Happy holidays string in the message variable.

The find() method will find the position of day.

If we look at the string Happy holidays we see that the word day is at the 10th position of the string.

H     1

a      2

p      3

p      4

y      5

h      6

o      7

l       8

i       9

d      10

a      11

y      12

s      13

So it is at 10th position so the statement

message.find("days")

returns 10

7 0
3 years ago
Other questions:
  • What type of attack intercepts communication between parties to steal or manipulate the data?
    13·1 answer
  • In cell R9, enter a formula using the AVERAGEIF function to determine the average number of years of experience for lifeguards.
    12·1 answer
  • NEED HELP NOW 25 POINTS!!!!!!
    15·2 answers
  • HELP ASAP
    9·1 answer
  • Which of the following combines something you know, such as a password, with something you are (a biometric device such as a fin
    13·1 answer
  • 334. Universal Containers uses a custom field on the account object to capture the account credit status. The sales team wants t
    12·1 answer
  • WILL GIVEE BRAINLIEST ANSWER!!!!
    14·1 answer
  • Write a C++ Programm in which inheritance is used
    7·1 answer
  • _____________are where you get down to business and enter data in a worksheet
    12·1 answer
  • Which engineer may design a GPS for a vehicle?
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!