Question: Suppose in a particular business all documents are given a one- character designation starting with either U, C, or P, standing for unclassified, confidential, or

Suppose in a particular business all documents are given a one-character designation starting with either U, C, or P, standing for unclassified, confidential, or proprietary. These codes are put in the names of the files, at the very beginning, followed by an underscore. For example, a file might be named U_QuarterOneData.txt or P_Numbers.txt design an exception class called InvalidDocumentCodeException, made to be thrown when the designation for a document is not U, C, or P. Implement this exception in a Driver class (in the same file) that asks the user for the names of files. When the program encounters a file with an invalid designation, it should throw an InvalidDocumentCodeException, catch it, and handle it by printing, "This document has an invalid code." Then, it should continue processing files. The program should end when the user inputs DONE.

Sample Run

Enterfilename:U_JuneData.txt Enterfilename:P_JulyData.txt Enterfilename:C_AugustData.txt Enterfilename:K_SeptemberData.txt Thisdocumenthasaninvalidcode. Enterfilename:C_OctoberData.txt Enterfilename:DONE 

Step by Step Solution

3.44 Rating (154 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

Solutions Step 1 This is the required program for your given problem statement import javautilScanner Custom exception class to handle invalid document codesclass InvalidDocumentCodeException extends ... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!