Question: Write a class InvalidCNICException that extends Exception class. The class should have the following details implemented A message property. override the following method that returns

Write a class InvalidCNICException that extends Exception class.

The class should have the following details implemented

–A message property. 

–override the following method that returns a message

  String to String()

–Two constructors

  1. With no parameter

  2. With String parameter

Take user input for CNIC. The CNIC is considered valid if

  1. The length of CNIC is 15(including -)

  2. if the hyphen(-) is present at position 6 and 14.

Generate (throw) Invalid CNIC Exception when an invalid CNIC has been entered by the user. Handle this exception by giving the user a responsive message saying "The CNIC you entered is not valid"  

SOLVE THIS IN JAVA LANGUAGE.


Step by Step Solution

3.39 Rating (152 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

InvalidCNICExceptionjava public class InvalidCNICException extends E... 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!