Question: C# Please 1. Write a switch statement that tests the value of my_var and performs the following actions: if my_var is 1, the message Option

C# Please

1.

Write a switch statement that tests the value of my_var and performs the following actions:

  • if my_var is 1, the message "Option 1 was selected." will be display.
  • if my_var is 2, the message "Option 2 was selected." will be display.
  • if my_var is 3, the message "Option 3 was selected." will be display.
  • other values will result in the message "Invalid option" will be displayed.

Assume that my_var was declared and initialize to a value already. You can also assume console namespace was declared too.

2. Convert the switch statement from the previous question into a nested (cascaded) if/else statement. You can still assume the variable my_var was declared and already initialized to a value.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!