1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Ostrovityanka [42]
3 years ago
12

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

Computers and Technology
1 answer:
Neko [114]3 years ago
8 0

Answer:

boolean rsvp;

int selection;

String option1;

String option2;

(a) if(rsvp){

System.out.println("Attending");

} else {

System.out.println("Not attending");

}

(b) if (selection == 1){

System.out.println("Beef");

} else if (selection == 2){

System.out.println("Chicken");

} else if (selection == 3) {

System.out.println("Pasta");

} else {

System.out.println("Fish");

}

(c) switch(selection){

case 1:

if(rsvp){

option1 = "Thanks for attending. You will be served beef.";

} else{

option1 = "Sorry you can't make it";

}

break;

case 2:

if(rsvp){

option1 = "Thanks for attending. You will be served chicken.";

} else{

option1 = "Sorry you can't make it";

}

break;

case 3:

if(rsvp){

option1 = "Thanks for attending. You will be served pasta.";

} else{

option1 = "Sorry you can't make it";

}

break;

default:

if(rsvp){

option1 = "Thanks for attending. You will be served fish.";

} else{

option1 = "Sorry you can't make it";

}

break;

}

(d) if (option1 == option2){

System.out.println("True");

} else {

System.out.println("False");

}

Explanation:

This code snippet is written in Java.

a) Uses if statement to print "attending" if rsvp is true and "not attending" if rsvp is false.

b) Uses if-else statement to print the variety of food based on user selection. If selection is 1, it print beef. If selection is 2, it print chicken. If selection is 3, it prints pasta else it print fish for any other value of selection.

c) Uses switch statement to determine the value of selection and then uses inner if statement to assign "Thanks for attending. You will be served beef." if rsvp is true to option1. The value of beef changes depending on the value of selection. If rsvp is false, then "Sorry you can't make it." is assigned to option1.

d) Uses if statement to print true if option1 and option2 are equal else it print false.

You might be interested in
Write a demo test to verify the above Rectangle object accessible from demo test main program and can execute display() method t
Sati [7]

Answer:

Explanation:

The Rectangle class was not provided in this question but after a quick online search I was able to find the class code. Due to this I was able to create a test code in the main Method of my program to create a Rectangle object and call it's display() method. The Test code and the output can be seen in the attached image below. While the code below is simply the Main Test Program as requested.

class Brainly {  

   public static void main(String[] args) {

       Rectangle rectangle = new Rectangle(20, 8);

       rectangle.display();

   }

}

4 0
2 years ago
Help me out on question 29 and 30 please
Elanso [62]

Answer:

It 5

Explain

number 28 is A and number 29 is 5

5 0
2 years ago
Which formula is properly constructed
kirill115 [55]

Answer:

Option 4 is correct ,=(B2+C9)

Explanation:

In excel a formula starts with an equal sign followed by the expression.

In first option the formula is incorrect inside the brackets. where 4 is equating to bracket. In 2nd option opening and closing brackets are not same. First closing bracket is missing an opening bracket. In third option all the formula is correct except the part where # is used in formula. Hash tags cannot be used in formula as a value. Here in option D  B2 and C9 are cell in excel, whereas parentheses are only used for better readability.

7 0
3 years ago
Which of the following is a group of computer systems and computing hardware devices linked together through various communicati
Art [367]
Digital network, as it refers to the series of connected and linked computing devices into a network as described in this question.
6 0
1 year ago
Given four files named asiasales2009.txt, europesales2009.txt, africasales2009.txt, latinamericasales2009.txt, define four ofstr
Lynna [10]

Answer:

ofstream asia("asiasales2009.txt");  //It is used to open asiasales2009.txt files with the asia objects.

ofstream europe("europesales2009.txt");  //It is used to open  europesales2009.txt files with the europe objects.

ofstream africa("africasales2009.txt"); //It is used to open africasales2009.txt files with the africa objects.

ofstream latin("latinamericasales2009.txt");//It is used to open latinamericasales2009.txt files with the latin objects.

Explanation:

  • The above code is written in the c++ language which is used to open the specified files with the specified objects by the help of ofstream class as described in the question-statements.
  • The ofstream is used to open the file in the c++ programing language, so when a user wants to use the ofstream to open the file in written mode, then he needs to follow the below syntax--

              ofstream object("file_name_with_extension");

4 0
3 years ago
Other questions:
  • What is the typical relationship between time and interest rate?
    12·1 answer
  • What protocol suite below is the most commonly used protocol for local area network (lan) communication?
    8·1 answer
  • Jane is debugging a code consisting of 25 lines. The code starts executing at line 11. At line 13, the code calls another method
    10·2 answers
  • Reasons for the growth of decision-making systems include:
    13·1 answer
  • What is a new ransomware program that encrypts your personal files and demands payment for the files' decryption keys? Multiple
    10·1 answer
  • Harold included an excerpt from an Internet magazine in an article he wrote for the school newspaper. However, he did not ask pe
    13·2 answers
  • .In Python, comments begin with the comment marker and continue ______.
    14·1 answer
  • Which memory can be removed from motherboard? RAM OR ROM?​
    11·1 answer
  • What is the outcome when a floating-point number is divided by zero?
    12·1 answer
  • Disadvantages of the divisional organization structure are _____. each division is able to operate independently from the parent
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!