Ask Question

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 December, 00:57
    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 & Technology if the answers seem to be not correct or there’s no answer. Try a smart search to find answers to similar questions.
Search for Other Answers