Ask Question
23 July, 21:41

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

+2
Answers (1)
  1. 24 July, 01:26
    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?
Find 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 and Technology if you're in doubt about the correctness of the answers or there's no answer, then try to use the smart search and find answers to the similar questions.
Search for Other Answers