Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Need this in PHP only. ASAP The program for this Assessment will consist of four sections, each headed by the three-line comment below: //********************************************************* //****Assessment

Need this in PHP only. ASAP

The program for this Assessment will consist of four sections, each headed by the three-line comment below:

//*********************************************************

//****Assessment 3 Program 1 Section X

//*********************************************************

(where X stands for the portion of the Assessment to follow.)

Assessment Requirements

Section 1:

Enter the comment with the section title as described above.

Print to the console the message, Assessment 6 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.

EXPECTED OUTPUT

Note: Error messages might differ from language to language and the file path as well.

Assessment 6 Asserts and Try/Catch.

(Here the two assert statements should create popup windows informing the user the string is null or empty and the integer should be greater than 0. Choosing to ignore the assertions should allow the program to continue.)

ArrayOutOfBounds error occurred

Index was outside the bounds of the array.

FileDoesNotExist error occurred

Could not find file

C:\ NoFileNamedThis.txt

DivideByZero error occurred

Divide By Zero

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

Database Application Development And Design

Authors: Michael V. Mannino

1st Edition

0072463678, 978-0072463675

More Books

Students also viewed these Databases questions

Question

What aspects would it be impossible to capture?

Answered: 1 week ago

Question

Enhance your words with effective presentation aids

Answered: 1 week ago