question archive I am trying to complete the assignment below in JAVA

I am trying to complete the assignment below in JAVA

Subject:Computer SciencePrice: Bought3

I am trying to complete the assignment below in JAVA... any assistance would be appreciated. The Expected Output section should help with any questions.

 

Assessment Requirements

1) Print the following messages to the console :

  • "Assessment 7 - Logging Exceptions to a File."

 

  • "Testing Try/Catch for Divide by Zero, File Does Not Exist, Array Out of Bounds, and Array is Null scenarios."

 

  • "All console error messages are printed from error log file."

 

2) Build a logfile. Redirect the stdErr stream to write to your logfile.

3) Build a function, DisplayLogfile(), that will read the logfile and display to the console.

4) Build a function named, DivideByZero(), which will attempt to divide a number by 0.

5) Build a function named, FileDoesNotExist(), which will attempt to open a non-existent file named, "NoFileNamedThis.txt".

6) Build a function named, ArrayOutOfBounds(), which will build an array and then try to access a non-existent index in that an array. (Hint: If there are 5 items in the array then the code might try to access item 6 for instance.)

7) Build a function named ArrayIsNull(), which will build an array and then set it equal to null before trying to access an item in the array.

8) Build a try/catch block.

a. From the try portion, call the function, DivideByZero().

b. In the catch portion, write the error message contained in the exception object to the standard error stream.

9) Build a try/catch block.

a. From the try portion, call the function, FileDoesNotExist().

b. In the catch portion, write the error message contained in the exception object to the standard error stream.

10) Build a try/catch block.

a. From the try portion, call the function, ArrayOutOfBounds().

b. In the catch portion, write the error message contained in the exception object to the standard error stream.

11) Build a try/catch block.

a. From the try portion, call the function, ArrayIsNull().

b. In the catch portion, write the error message contained in the exception object to the standard error stream.

12) Call the DisplayLogFile() function to display the contents of the log file your program has created.

 

EXPECTED OUTPUT

 

Assessment 7 - Logging Exceptions to a File.

 

Testing Try/Catch for Divide by Zero, File Does Not Exist, Array Out of Bounds, and Array is Null scenarios.

 

All console error messages are printed from error log file.

 

Attempted to divide by zero.

 

Could not find file 'C:NoFileNamedThis.txt'

 

Index was outside the bounds of the array.

 

Object reference not set to an instance of an object.

pur-new-sol

Purchase A New Answer

Custom new solution created by our subject matter experts

GET A QUOTE