Ask Question
22 March, 16:08

Assume that the following variables have been properly declared and initialized.

1. a boolean variable named rsvp

2. an int variable named selection, where 1 represents "beef", 2 represents "chicken", 3 represents "pasta", and all other values represent "fish"

3. a String variable named option1

4. a String variable named option2

Write a code segment that will print true if the strings option1 and option2 contain the same values and will print false otherwise

+1
Answers (1)
  1. 22 March, 18:03
    0
    if (option1. equals (option2)) {

    rsvp = true;

    }

    System. out. println (rsvp);

    A full program is given in the explanation section

    Explanation:

    import java. util. Scanner;

    public class Option {

    public static void main (String[] args) {

    boolean rsvp = false;

    int selection;

    String option1, option2;

    Scanner in = new Scanner (System. in);

    option1 = in. next ();

    option2 = in. next ();

    if (option1. equals (option2)) {

    rsvp = true;

    }

    System. out. println (rsvp);

    }

    }
Know the Answer?
Not Sure About the Answer?
Get an answer to your question ✅ “Assume that the following variables have been properly declared and initialized. 1. a boolean variable named rsvp 2. an int variable named ...” in 📙 Computers & Technology if there is no answer or all answers are wrong, use a search bar and try to find the answer among similar questions.
Search for Other Answers