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
When you merge business letters, how many total documents will you have when you are finished with the merge process?
dlinn [17]

Answer:

You will have one letter for every receiver on the table.

Explanation:

In a new Microsoft Word paper, click on the Mailings label, and in the Start Mail Merge collection, agree on Start Mail Merge.

Agree on Step-by-Step Mail Merge Wizard.

Choose your paper model.

Choose the opening paper.

Preferred beneficiaries.

Address the report and attach your custom entries.

6 0
3 years ago
Read 2 more answers
Which website can help you find antivirus software ?
sergey [27]

If you have windows you have Windows Defender Installed already!!

5 0
3 years ago
How might your use of computers and knowledge of technology systems affect your personal and professional success?
RUDIKE [14]
It can help you more be aware of whats going on and what you need to do.
8 0
2 years ago
Before donating a computer you should use a program to wipe the hard disk to remove all of its data
Elenna [48]
Yes you should. highly recommended
7 0
2 years ago
Read 2 more answers
Match the Job description with the job titles.
koban [17]
1) Bricklayer 2) Roofer 3) Architectural drafter 4) landscape architect
6 0
2 years ago
Read 2 more answers
Other questions:
  • Consider the relation Courses(C, T, H, R, S, G), whose attributes can be thought of informally as course (C), teacher (T), hour
    10·1 answer
  • What is an identifier? Give an example of an identifier.
    13·1 answer
  • Implement a java program to find the smallest distance between two neighbouring numbers in an array.
    7·1 answer
  • Your computer will organize files into
    6·2 answers
  • People using commercially available software are usually asked to read and agree to a(n) _____
    10·1 answer
  • Which term is defined as an exploit that takes place before the security community or software developer knows about the vulnera
    12·1 answer
  • Choose the HTML5 element below that is used to configure an area on a web page that can stand on its own and could potentially b
    5·1 answer
  • There is a file of a few Sean Connery movies on the internet. Each entry has the following form:
    9·1 answer
  • DERECTIONS: Identify all the computer software that you need for the following entrepreneurial activities. Refer your answer fro
    5·1 answer
  • Im coding and need help please answer or comment to help. any skilled coders comment below
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!