Question: Write a program by following these instructions: Create 2 custom Exception classes, one which defines a name mistake and another which defines a student number

Write a program by following these instructions:
Create 2 custom Exception classes, one which defines a name mistake and another which defines a student number mistake. Both must at least contain a constructor which sets a custom message
Write a program that asks the user to enter their name and then their student number into the console. If the name entered is not your name, throw the custom name Exception with a custom error message. If the student number entered is not your student number, throw the custom student number Exception with a custom error message.
If an Exception is thrown, prompt the user to input the name or student number again. After 5 unsuccessful attempts, end the program.
b)Create another version of part a)(in a different class) which accepts a name and student number from the user, then reads from a text file to see if they are valid:
Maintain the same functionality as part a). Throw the corresponding Exception if an incorrect name/number is entered. End the program after 5 unsuccessful attempts.
The Scanner class can be used for the file input.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock 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!