Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Use inheritance to create a hierarchy of Exception classes EndOfSentenceException, PunctuationException, and CommaException. EndOfSentenceException is the parent class to PunctuationException, which is the parent class

image text in transcribed

Use inheritance to create a hierarchy of Exception classes EndOfSentenceException, PunctuationException, and CommaException. EndOfSentenceException is the parent class to PunctuationException, which is the parent class to CommaException Test your classes in a Driver class with a main method that asks the user to input a sentence. If the sentence ends in anything except a period), exclamation point (), or question mark(?), the program should throw a PunctuationException. If the sentence specifically ends in a comma, the program should throw a CommaException. Use a catch block to catch all EndOfSentenceExceptions, causing the program to print a message and terminate. If a general PunctuationException is caught, the program should print "The sentence does not end correctly." If a CommaException is caught, the program should print "You can't end a sentence in a comma." If there are no exceptions, the program should print "The sentence ends correctly." and terminate. SAMPLE RUN #3: java Driver Hide Invisibles Highlight: None Show Highlighted OnlyU Enter-a-sentence:In my-younger and more-vulnerable-years my father.gave-me.some advice-that I've been turning-over.in-my mind-ever since The. sentence. does not.end correctly. SUBMIT 2 of 2: Tue Oct 02 2018 07:40:56 GMT-0700 (Pacific Daylight Time)

Step by Step Solution

There are 3 Steps involved in it

Step: 1

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

Advanced Oracle Solaris 11 System Administration

Authors: Bill Calkins

1st Edition

0133007170, 9780133007176

More Books

Students also viewed these Databases questions