Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Could I please get this in Java. 1. Print to the console the following messages: - Assessment 7 - Logging Exceptionsto a File. - Testing

Could I please get this in Java.

image text in transcribed

1. Print to the console the following messages: - "Assessment 7 - Logging Exceptionsto 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. Create a logfile. Redirect the stdErr stream to write to your logfile. 3. Create a function, DisplayLogfile(), that will read the logfile and display to the console. 4. Create a function named, DivideByZero(), which will attempt to divide a number by 0 . 5. Create a function named, FileDoesNotExist(), which will attempt to open a non-existent file named, "NoFileNamedThis.txt". 6. Create a function named, ArrayOutOfBounds(), which will create 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. Create a function named ArraylsNull(), which will create an array and then set it equal to null before trying to access an item in the array. 8. Create 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. Create 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. Create 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. Create a try/catch block. a. From the try portion, call the function, ArraylsNull(). 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 Note: Error messages might differ from language to language and the file path as well. 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.INoFileNamedThis.txt' Index was outside the bounds of the array

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

SQL Server Query Performance Tuning

Authors: Sajal Dam, Grant Fritchey

4th Edition

1430267429, 9781430267423

More Books

Students also viewed these Databases questions

Question

What is the Definition for Third Normal Form?

Answered: 1 week ago

Question

Provide two examples of a One-To-Many relationship.

Answered: 1 week ago