78.0k views
4 votes
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.

User Daneau
by
7.8k points

1 Answer

3 votes

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. }

Step-by-step 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".

User Jlliagre
by
8.0k points
Welcome to QAmmunity.org, where you can ask questions and receive answers from other members of our community.