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
Which is the best description of a hierarchical report?
mixas84 [53]

Answer:

d

Explanation:

a report with records sorted in ascending order is the right answer

6 0
3 years ago
What two things should you do before starting the design process
Charra [1.4K]

Answer: B and C

Explanation: Analyze the audience

                      Identify the problem

8 0
2 years ago
What feature of the new internet browser, microsoft edge, allows you to write or draw on a web page, highlight items, erase your
hodyreva [135]
Web Note. You can access the feature by selecting "Make a web note" and several options on the toolbar will pop up for use. Microsoft has a help page here: https://support.microsoft.com/en-us/help/17221/windows-10-write-on-the-web
6 0
3 years ago
Which access method would be most appropriate if your manager gave you a special cable and told you to use it to configure the s
GrogVix [38]
Console Port Method

Connecting a computer to a Cisco device through the console port requires a special console cable.
8 0
2 years ago
In PowerPoint, a type of chart that, rather than showing numerical data, illustrates a relationship or logical flow between diff
Lynna [10]

Answer:

A. SmartArt

Explanation:

SmartArt is a graphical tool used to visually communicate information.

8 0
3 years ago
Other questions:
  • Nicole wants to create a database to collect information about sales transactions. She would like to use the database to look up
    6·2 answers
  • When you declare a string data type, you are actually creating an object from the?
    5·1 answer
  • Select the correct answer.
    13·1 answer
  • ____________ is a widely accepted international best practices framework for implementing information systems security.
    12·1 answer
  • Communications that take the form of electronic junk mail or unsolicited e-mail are referred to as
    13·2 answers
  • You want to boot a linux system into singer user mode/ what options might you add to a linux kernel options list in a boot loade
    9·1 answer
  • Data cannot be sorted or filterd accuratly if there are ________.
    12·1 answer
  • I have wings, I am able to fly, I‘m not a bird yet I soar high in the sky. What am I?
    14·2 answers
  • Requests to retrieve data written in a language such as SQL are called…
    8·1 answer
  • What does ""fair use"" mean regarding copyrighted works?
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!