1. Create an exception class called SocSecException. The UML diagram for this class is below. SocSecException + SocSecException(error: String): The constructor will call the superclass constructor. It will set the message associated with the exception to "Invalid social security number" concatenated with the error string. 2. Create a driver program called SocSecProcessor. This program will have a main method and a static method called isValid that will check if the social security number is valid. SocSecProcessor + main(args : String[]): void + isValid(ssn : String): boolean Copyright © 2019 Pearson Education, Inc., Hoboken NJ Task #2 Writing Code to Handle an Exception 1. In the main method: a. The main method should read a name and social security number from the user as String objects. b. The main method should contain a try-catch statement. This statement tries to check if the social security number is valid by using the method isValid. If the social security number is valid, it prints the name and social security number. If a SocSecException is thrown, it should catch it and print out the name, social security number entered, and an associated error message indicating why the social security number is invalid. c. A loop should be used to allow the user to continue until the user indicates that they do not want to continue. 2. The static isValid method: a. This method throws a SocSecException. b. Returns true if the social security number is valid, false otherwise. c. The method checks for the following errors and throws a SocSecException with the appropriate message. i) Number of characters not equal to 11. (Just check the length of the string) ii) Dashes in the wrong spots. iii) Any non-digits in the SSN. iv) Hint: Use a loop to step through each character of the string, checking for a digit or hyphen in the appropriate spots.

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question
1. Create an exception class called SocSecException. The UML diagram for
this class is below.
SocSecException
+ SocSecException(error: String) :
The constructor will call the superclass constructor. It will set the message associated
with the exception to "Invalid social security number" concatenated with the error string.
2. Create a driver program called SocSecProcessor. This program will have a
main method and a static method called isValid that will check if the social
security number is valid.
SocSecProcessor
+ main(args : String[]): void
+ is Valid(ssn: String): boolean
Copyright © 2019 Pearson Education, Inc., Hoboken NJ
Task #2 Writing Code to Handle an Exception
1. In the main method:
a. The main method should read a name and social security number from the
user as String objects.
b.
The main method should contain a try-catch statement. This statement
tries to check if the social security number is valid by using the method
isValid. If the social security number is valid, it prints the name and social
security number. If a SocSecException is thrown, it should catch it and
print out the name, social security number entered, and an associated error
message indicating why the social security number is invalid.
c. A loop should be used to allow the user to continue until the user indicates
that they do not want to continue.
2. The static isValid method:
a. This method throws a SocSecException.
b. Returns true if the social security number is valid, false otherwise.
c. The method checks for the following errors and throws a
SocSecException with the appropriate message.
i) Number of characters not equal to 11. (Just check the length of the string)
ii) Dashes in the wrong spots.
iii) Any non-digits in the SSN.
iv) Hint: Use a loop to step through each character of the string, checking for
a digit or hyphen in the appropriate spots.
Transcribed Image Text:1. Create an exception class called SocSecException. The UML diagram for this class is below. SocSecException + SocSecException(error: String) : The constructor will call the superclass constructor. It will set the message associated with the exception to "Invalid social security number" concatenated with the error string. 2. Create a driver program called SocSecProcessor. This program will have a main method and a static method called isValid that will check if the social security number is valid. SocSecProcessor + main(args : String[]): void + is Valid(ssn: String): boolean Copyright © 2019 Pearson Education, Inc., Hoboken NJ Task #2 Writing Code to Handle an Exception 1. In the main method: a. The main method should read a name and social security number from the user as String objects. b. The main method should contain a try-catch statement. This statement tries to check if the social security number is valid by using the method isValid. If the social security number is valid, it prints the name and social security number. If a SocSecException is thrown, it should catch it and print out the name, social security number entered, and an associated error message indicating why the social security number is invalid. c. A loop should be used to allow the user to continue until the user indicates that they do not want to continue. 2. The static isValid method: a. This method throws a SocSecException. b. Returns true if the social security number is valid, false otherwise. c. The method checks for the following errors and throws a SocSecException with the appropriate message. i) Number of characters not equal to 11. (Just check the length of the string) ii) Dashes in the wrong spots. iii) Any non-digits in the SSN. iv) Hint: Use a loop to step through each character of the string, checking for a digit or hyphen in the appropriate spots.
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 4 steps with 1 images

Blurred answer
Knowledge Booster
Exception Handling Keywords
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education