Question

Write a switch statement that uses the colour of a swab sample of COVID testing vehicle...

Write a switch statement that uses the colour of a swab sample of COVID testing vehicle to send a message to a local doctor. Use the messages given for each colour in the table below. Justify your answer.                                                                                        

Homework Answers

Answer #1

The switch statement allows us to execute a block of code among many alternatives

syntax

switch (expression)  {
    case constant1:
        // code to be executed if 
        // expression is equal to constant1;
        break;

    case constant2:
        // code to be executed if
        // expression is equal to constant2;
        break;
        .
        .
        .
    default:
        // code to be executed if
        // expression doesn't match any constant
}

code:

String color ="user defined color";

switch(color){

case blue:

System.out.println("no virus");

break;

case yellow:

System.out.println("N to be under observation");

break;

case red:

System.out.println("Need top be admitted in the covid ward");

break;

}

here the switch statement will take the color and display the message the corresponding message to the local doctor.

please
upvote if find useful.

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
Write a switch statement that uses the colour of a swab sample of COVID testing vehicle...
Write a switch statement that uses the colour of a swab sample of COVID testing vehicle to send a message to a local doctor. Use the messages given for each colour in the table below. Justify your answer.                                                                                         Colour Message Blue “No virus” Yellow “Needs to be under observation” Red “Needs to be admitted in COVID ward”
Write a switch statement that uses the colour of a swab sample of COVID testing vehicle...
Write a switch statement that uses the colour of a swab sample of COVID testing vehicle to send a message to a local doctor. Use the messages given for each colour in the table below. Justify your answer.                                                                                         Colour Message Blue “No virus” Yellow “Needs to be under observation” Red “Needs to be admitted in COVID ward”
Write a switch statement that uses the colour of a swab sample of COVID testing vehicle...
Write a switch statement that uses the colour of a swab sample of COVID testing vehicle to send a message to a local doctor. Use the messages given for each colour in the table below. Justify your answer. Colour Message Blue “No virus” Yellow “Needs to be under observation” Red “Needs to be admitted in COVID ward”
Write a switch statement that uses the colour of a swab sample of COVID testing vehicle...
Write a switch statement that uses the colour of a swab sample of COVID testing vehicle to send a message to a local doctor. Use the messages given for each colour in the table below. Justify your answer.                                                                                         Colour Message Blue “No virus” Yellow “Needs to be under observation” Red “Needs to be admitted in COVID ward”
In C++ Please, In the main(), below, write a program that uses a switch-statement to choose...
In C++ Please, In the main(), below, write a program that uses a switch-statement to choose between three numbers. The number, choice, should be prompted for and each choice should print out a unique statement. Also, the prompt should continue indefinitely (i.e. keep prompting until the user force-quits the program), and there should be a general catch-all if the user enters other than the three possible choices. #include <iostream> #include <iomanip> using namespace std; int main() { <your answer goes...
Re-write following if-else-if statements as Switch statement. Your final code should result in the same output...
Re-write following if-else-if statements as Switch statement. Your final code should result in the same output as the original code below. if (selection == 10) System.out.println("You selected 10."); else if (selection == 20) System.out.println("You selected 20."); else if (selection == 30) System.out.println("You selected 30."); else if (selection == 40) System.out.println("You selected 40."); else System.out.println("Not good with numbers, eh?"); Second question Re-write following while loop into Java statements that use a Do-while loop. Your final code should result in the same...
Q1: Re-write following if-else-if statements as Switch statement. Your final code should result in the same...
Q1: Re-write following if-else-if statements as Switch statement. Your final code should result in the same output as the original code below. if (selection == 10) System.out.println("You selected 10."); else if (selection == 20) System.out.println("You selected 20."); else if (selection == 30) System.out.println("You selected 30."); else if (selection == 40) System.out.println("You selected 40."); else System.out.println("Not good with numbers, eh?"); Q2: Re-write following while loop into Java statements that use a Do-while loop. Your final code should result in the same...
1. Given the following multi-way if statement, provide a switch statement, using proper java syntax, that...
1. Given the following multi-way if statement, provide a switch statement, using proper java syntax, that will provide the same function. Char grade; String tstmsg; if (grade == ‘A’) {   tstmsg = “Excellent”; } else if (grade == ‘B’) {   tstmsg = “Good”; } else if (grade == ‘C’) {   tstmsg = “OK”; } else {   tstmsg = “Study More”; } 2.Write the following for statement as a while statement. for (k = 0; k < 3; k++) {   System.out.println...
Use the following tables to answer Q5 and Q6. Tourist (tno, Name, phone, age,loc) Vehicle (Vno,...
Use the following tables to answer Q5 and Q6. Tourist (tno, Name, phone, age,loc) Vehicle (Vno, model, mileage, owner_name, owner_ph)) Rented (tno, Vno) 5. (i)Write an SQL query, to create the table vehicle with following constraints: Vno should begin with second letter ‘v’; Models are one among Thar, X3. Mileage should be above 18 and below 25. No two records can have same phone (ii) Write an SQL query to retrieve the name of the owner who does owns X3...
Test the claim using the traditional method of hypothesis testing. Assume that the sample haas been...
Test the claim using the traditional method of hypothesis testing. Assume that the sample haas been randomly selected from a population with a normal distribution. Use a significance level of alpha = 0.01 to thest the claim that mu > 2.85. The sample data consists of 9 scores for which x-bar = 3.16 and s = 0.6. Separate each answer with a comma. What is the test statistic, write the number only? What is the critical value, write the number...