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
alexira [117]
3 years ago
14

A boolean variable named rsvp an int variable named selection, where 1 represents "beef", 2 represents "chicken", 3 represents "

pasta", and all other values represent "fish" a String variable named option1 a String variable named option2. Write a code segment that prints "attending" if rsvp is true and prints "not attending" otherwise. Write the code segment below.
Computers and Technology
1 answer:
Maru [420]3 years ago
6 0

Answer:

int main()

{

   bool rsvp;

   string option1,option2="Not attending";

   int selection;

   cin>>rsvp;    //rsvp value to be entered by user

   if(rsvp=true)     //to check if rsvp is true

   {

       cin>>selection;     //only if rsvp is true then selection's value would matter

       switch(selection)             //to appoint right value to option1

       {

           case 1 : option1="Attending you will be served beef";

           exit;

           case 2 : option1="Attending you will be served chicken";

           exit;

           case 3 : option1="Attending you will be served pasta";

           exit;

           default : option1="Attending you will be served fish";   //any other integer will have value fish

           exit;

       }

       cout<<option1;

   }

   else

       cout<<option2;      //if false then option2 will be printed

   return 0;

}

Input :

true

2

Output :

Attending you will be served chicken

Explanation:

The question is incomplete as it has missed other 2 code segments which states that option1 and option2 are printed strings which tells attending or not attending. Also, selection is the integer value for the food to be served if attending or rsvp is true.

In the above code, first rsvp value is taken from the user and checked if true or false. If rsvp is true then selection is read from user as otherwise its value won't matter. Then option1 string is initiated according to the va.lue given and printed to the user. If rsvp is false then direct option2 string is outputted which is "not attending".

You might be interested in
What does NIC stand for?
evablogger [386]
Network Interface Controller
6 0
3 years ago
How do you comment on someone's answer on Brainly???
Semenov [28]
Press ANSWER , and reply
5 0
3 years ago
Which windows component can be used to display information such as weather forecasts?
azamat
The bottom right widgeti
6 0
3 years ago
I NEED TO FIND OUT THE ANSWER!
vladimir1956 [14]

Answer:

the first action that should be taken is to back up the all important document that and by finishing doing that format the entire system...and i advise you should be choosing the best antivirus to protecting your computer

7 0
3 years ago
I REALLY NEED HELP WITH THIS ASSIGNMENT. IT WOULD BE GREATLY APPRECIATED IF SOMEONE HELPED ME. I'M NOT GOOD AT COMPUTER SCIENCE
melomori [17]

Answer:

Explanation:

i cant view it

8 0
3 years ago
Read 2 more answers
Other questions:
  • The _______ has shortcuts to commonly used commands
    8·2 answers
  • ____ is a special type of large, integrated system that ties together all types of a company’s activities, such as planning, man
    11·2 answers
  • Wireshark capture files, like the DemoCapturepcap file found in this lab, have a __________ extension, which stands for packet c
    6·1 answer
  • Hidden costs of computers into our schools
    13·1 answer
  • .<br> 1. Press the _______ key to move to the next cell in a row.
    14·2 answers
  • Which is the correct sequence of steps for opening a new document?
    10·2 answers
  • Mrs. Jackson wrote a newsletter to the customers of her housecleaning business that included some organizational tips they could
    8·2 answers
  • Please debug the below code in Java please.
    15·1 answer
  • It is a data being transported on a network​
    13·1 answer
  • What is the difference between a field and an infoobject? What is the advantage of using infoobjects instead of fields in an ads
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!