Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

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

Statistics For Business And Economics

Authors: Paul Newbold, William Carlson, Betty Thorne

8th Edition

0132745658, 978-0132745659

More Books

Students also viewed these Programming questions