Answered step by step
Verified Expert Solution
Question
1 Approved Answer
CREATE USING C# ONLY PLEASE Section 1 : Enter the comment with the section title as described above. Print to the console the message
CREATE USING C# ONLY PLEASE
Section :
Enter the comment with the section title as described above.
Print to the console the message INM Assessment Part Asserts and TryCatch
Create a string variable and set its value to null or empty.
Create an integer variable and set it to
Note: The variables above are initialized to values intended to trigger the following assert statements.
Create an assert statement to validate that the string variable is not empty or null with the message "Parameter must not be empty or null."
Create an assert statement to validate that the integer variable is greater than zero with the message "Parameter must be greater than zero."
Section :
Enter the comment with the section title as described above.
You will create an array of strings.
You will create a trycatch block.
In the try portion of the trycatch you will loop through the array using a 'for loop' where your index variable begins at and the loop continues as long as the
index is the length of the array. This will cause an array out of bounds error where the loop attempts to access an array index value that is one more than the
last item.
The catch portion will catch the out of bounds exception. Inside the catch block, you will write two lines to the console. The first simply prints the string, "Array out
of bounds error occurred." On a new line, you will then print the error message contained in the exception object.
Section :
Enter the comment with the section title as described above.
You will create a trycatch block.
In the try portion of the trycatch you will attempt to open a nonexistent file named "NoFileNamedThis.txt
The catch portion will catch the file not found exception. Inside the catch block, you will write two lines to the console. The first simply prints the string, "File not
found error." On a new line, you will then print the error message contained in the exception object.
Section :
Enter the comment with the section title as described above.
You will create a function, called "DivideByZero", which will allow for two integer operands, dividend and divisor.
The function will check to be sure the divisor is not equal to zero.
If the divisor is equal to then the function will throw an exception with the message "Divide by Zero."
You will create a trycatch block.
In the try portion you will call the function DivideByZero and pass it two numbers with the second being to cause an error.
The catch portion will catch the Divide By Zero exception thrown by the function. Inside the catch block, you will write two lines to the console. The first simply
prints the string, "DivideByZero error occurred." On a new line, you will then print the error message contained in the exception object.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started