Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

2. Now , create a new project and name its main class (and file ) as SwitchStatement . Implement another version of the above program

image text in transcribed
image text in transcribed
2. Now , create a new project and name its main class (and file ) as SwitchStatement . Implement another version of the above program by writing the following code. Console.WriteLine("Enter a number (as an integer): "); int number = Convert. ToInt32(Console. ReadLine()); switch (number) case 1: Console.WriteLine("One"); break; case 2: Console.WriteLine("Two"); break; default: Console.WriteLine("Error: you must enter an integer between 1 and 9"); break; Console. ReadLine(); Complete the rest of the case statements up to 9 (between case 2 and default ). Run the program and check whether its output is as expected. Test it with the following: All nine integers between 1 and 9. - A few other integers outside this range , i.e. 10 and 100 . What happens if you enter -5? What happens if you enter a letter , e.g. 'a'? How can you add an error message to catch this ? 3. Find all existing issues with the code snippets presented below . It is highly important to try working this out on paper by tracing through the statements and then input the code into your IDE . Run it to see if you are correct , and then see if you can fix the code int number = 50 ; if ( number = = 50 ) ; { Console . WriteLine ( "Number is 50" ) ; int number = 60 ; ( number > = = 50 and number 40{ Console . WriteLine ("You passed the exam !") ; } else score

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Foodservice Management Principles And Practices

Authors: June Payne Palacio, Monica Theis

13th Edition

0133801101, 9780133801101

More Books

Students also viewed these General Management questions