Question: A palindrome is a string that reads the same forwards and backwards, disregarding punctuation and the distinction between uppercase and lowercase letters. Write a Java
A palindrome is a string that reads the same forwards and backwards, disregarding punctuation and the distinction between uppercase and lowercase letters.
Write a Java program which accepts an input string from the user and determines whether it is a palindrome.
Your program should contain three classes:
The StackX class which is included below
The PalindromeApp class which should contain the main() method. Your main() method should prompt the user to enter the input string and loop continually until the user enters q to quit.
The Palindrome class which contain a boolean method isPalindrome(). The isPalindrome() method should return true if the input string is a palindrome and false otherwise.
Your program must implement the stack data structure.
Suggested algorithm: Transfer the input string to a working string with all lowercase letters. Use two stacks and proceed as follows. Grab each character from the working string. If it is a letter, push it onto Stack 1. After the working string is consumed, repeatedly pop a letter from Stack 1 and push it onto Stack 2 until half the letters have been transferred. Then determine if the two stacks are equal.
Sample I/O:

StackX class:

Enter a string (a to quit): LEVEL LEVEL is a Palindrome. Enter a string (a to quit): Grad Day! No more classes from Rambally! Grad Day! No more classes from Rambally! is not a Palindrome. Enter a string (a to quit): Able was I, ere I saw Elba. Able was I, ere I saw Elba. is a Palindrome. Enter a string (a to quit): a
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
