Question: Create a Java program that prompts the user to input a string into a JOptionPane showInputDialog. It should check if the inputted word is a
Create a Java program that prompts the user to input a string into a JOptionPane showInputDialog. It should check if the inputted word is a palindrome (same spelling forward and backward) and output a JOptionPane MessageDialog if it is.
Your program should throw exceptions that you catch if:
The entry is null (when you click cancel) The word contains a non-alphabetic character You enter your own name(Steven)
The program should end when you type in "exit" in any case (Exit, exit, eXit, etc should all work).
Create classes for each exception that extend the exception class. Remember to call the parent class constructor using the keywork super() . When you catch an exception, output an appropriate message to the terminal that identifies which exception was caught. Somewhere in your program you should also have method that handles the inputted strings that throws the exceptions you have made.
When checking if the inputted string is a palindrome, throw an exception if the word contains a character that isn't in the alphabet ($, @, !, 1, 2, etc). It should be case sensitive as well ("Hannah" should not work, "hannah" should work). You only need to worry about palindromes that are one word long. Attempt to make you program work for palindromes that are more than one word (top spot, etc).
Use JavaDoc to comment your program, remembering to comment each class and method.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
