Answered step by step
Verified Expert Solution
Link Copied!

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 1:
Enter the comment with the section title as described above.
Print to the console the message "IN255M3 Assessment Part 1- Asserts and Try/Catch."
Create a string variable and set its value to null or empty.
Create an integer variable and set it to 0.
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 2:
Enter the comment with the section title as described above.
You will create an array of strings.
You will create a try/catch block.
In the try portion of the try/catch, you will loop through the array using a 'for loop' where your index variable begins at 0 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 3:
Enter the comment with the section title as described above.
You will create a try/catch block.
In the try portion of the try/catch, you will attempt to open a non-existent 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 4:
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 0, then the function will throw an exception with the message "Divide by Zero."
You will create a try/catch block.
In the try portion you will call the function DivideByZero and pass it two numbers with the second being 0 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.
image text in transcribed

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_2

Step: 3

blur-text-image_3

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

MFDBS 91 3rd Symposium On Mathematical Fundamentals Of Database And Knowledge Base Systems Rostock Germany May 6 9 1991

Authors: Bernhard Thalheim ,Janos Demetrovics ,Hans-Detlef Gerhardt

1991st Edition

3540540091, 978-3540540090

More Books

Students also viewed these Databases questions

Question

Discuss the general principles of management given by Henri Fayol

Answered: 1 week ago

Question

Detailed note on the contributions of F.W.Taylor

Answered: 1 week ago

Question

2. What are the components of IT infrastructure?

Answered: 1 week ago