Question: B (3) (5 marks) Create and test a C# console application that does the following: (1) Create a variable of the int data type, named

 B (3) (5 marks) Create and test a C# console application

B (3) (5 marks) Create and test a C# console application that does the following: (1) Create a variable of the int data type, named marks: (2) Create a variable of the string data type, named grade; (3) Use the built-in function Console.ReadLine() to get the user's input for marks as follows (it is assumed that the user always inputs integers when testing this program): Console.WriteLine("Input the marks:"); marks = Convert.ToInt32(Console.ReadLine(); (4) Convert marks into grade as follows using an else-if statement: marks grade 90-100 A+ 85-89 80-84 A- 77-79 B+ 73-76 70-72 B- 67-69 C+ 63-66 60-62 C- 50-59 D 0-49 F (5) Display the value of grade in the console window using the following statement: Console.WriteLine("The grade is " + grade); (4) (4 marks) Repeat Question 3 using the switch statement (instead of the else-if statement). For simplicity, you may assume the user always inputs an integer between 0 and 100. Hint: The switch statement is a lengthy one and is similar to the following: switch (marks) { case 90: case 91: case 92: case 93: case 94: case 95: case 96: case 97: case 98: case 99: case 100: grade = "A+": break; case 85: case 86: case 87: case 88: case 89: grade = "A"; break; case 50: case 51: case 52: case 53: case 54: case 55: case 56: case 57: case 58: case 59: grade = "D"; break; default: grade = "F"; break; }

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!