Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

FleetU 1-xythos.$3.us-east-1.amazonaws.com/SUBUSUL 1) Introduction to Methods (with Debugging) In the first part of this lab, we would like to introduce you to methods, parameter passing,

image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
FleetU 1-xythos.$3.us-east-1.amazonaws.com/SUBUSUL 1) Introduction to Methods (with Debugging) In the first part of this lab, we would like to introduce you to methods, parameter passing, and the helpfulness of the Debugger. a) Enter the following program (use Lab3_1 for both the Project and Code File names). This program out a corresponding letter grade for a given mark. It uses a method (called MarktoGrade) to determine the letter grade. MarktoGrade takes one integer call by value formal parameter (called mark) and returns a char value that is the letter grade. All of the input and output (except an error message) is done in Main. There is one syntax error in this program that you will need to fix before it will compile (the error is in the line where the method is called). Please note that there is a text version of this program named Lab3 1.txt (without the line numbers) available in the Labs folder on BlackBoard for copying and pasting. Also, please be aware that the line numbers in the lab exercise may not be the same as the line numbers you see in Visual Studio 1. using System; 2. public static class Lab3 1 public static void Main() // declare variables int inpMark: string last Name char grade- 9. 10. 11. 13. // enter the student's last name Console.Write("Enter the last name of the student -> "); lastName - Console.ReadLine(); // enter and validate the mark do 16. 11 Console.Write("Enter a mark between 0 and 100 => "); inpark - Convert.ToInt32 (Console.ReadLine()); while (inpMark Olinpark > 100); 21. 1/ Use the method to convert the mark into a letter grade grade - MarkToGrade(); 1/ print out the results Console.WriteLine("{0)'s mark of inpark, grade) Console.ReadLine(); 1) converts to a 121 lastName, 25 26. 27. go 01-xvthos.s3.us-east-1.amazonaws.com/5b8eb3Ueya 185/15860327 response-content-dispositi 25. 26. inpMark, grade); Console.ReadLine(); // Method: MarkToGrade // Parameter 77 mark: call by value parameter to be converted to a letter grade 32. 33. // Returns: the corresponding letter grade public static char MarkToGrade (int mark) 34. char letterValue; 36. 40. 41. 42. 43. // multi-alternative If statement to determine letter grade if (mark > 0 && mark 50 && mark 60 66 mark = 75 && mark = 85 && mark Change Line 21 to be: MarkToGrade (inpMark, ref grade); Run the program with the input of Smith and 98. What is the output? What do you notice about the output relative to what you saw in Part (b)? Why did we have to remove Line 35 (try putting it back in)? What did we have to remove Line 55 (try putting it back in)? Why did the method call (invocation) in Line 21 have to change? k) One last set of changes to the program from Part (1). In the method call (Line 21), change it to grade = MarkToGrade (inpMark); What error message did you receive and why? What if we change Line 21 to: grade = MarkToGrade (inpMark, ref grade); What error message did you receive and why? Finally, how about if we change Line 21 to: MarkToGrade (ref grade, inpMark); What error messages did you receive and why? Answer all the highlighted questions in a file and then submit a PDF of this file (called it Lab3 1.pdf) to the Lab 3 dropbox. When asked "What is the output", simply type in what is seen in the output window

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

Graph Databases In Action

Authors: Dave Bechberger, Josh Perryman

1st Edition

1617296376, 978-1617296376

More Books

Students also viewed these Databases questions