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 (a) Write a code segment that prints "attending" if rsvp is true and prints "not attending" otherwise. Write the code segment below.

Respuesta :

Answer:

The code segment is written in Java.

  1.        boolean rsvp = true;
  2.        int selection;
  3.        String option1;
  4.        String option2;
  5.        if(rsvp == true){
  6.            System.out.println("attending");
  7.        }else{
  8.            System.out.println("not attending");
  9.        }

Explanation:

Declare all the variables as required by the question (Line 1 - 4).

Create a control structure using if-else statements so that when rsvp equal to true, the program will display "attending" else it will display "not attending".

 

Answer:

#include <iostream>

int main() {

   bool rsvp = false;

   int selection;

   string option1, option2;

   if (rsvp == true) {

       cout<<"Attending \n" ;

   }  else {

       cout<<"Not Attending \n";

   }

   return 0;

}

Explanation:

I'm not sure if there's something more to this exercise, but the above code is what you want, based on the question.