Question: Have to create the stack and this is for java. Write a program in Java to test for palindromes using a stack. You are not

Have to create the stack and this is for java. Write a program in Java to test for palindromes using a stack. You are not allowed to use Java API Stack classes for this problem. A palindrome is a string that reads the same way forwards and backwards. Your program should do the following steps. 1. Prompt the user at command line to enter a string. 2. Convert the input string to lower case. 3. Push each letter character of the string on the stack until the string ends. Do not push blank spaces, special characters or punctuation marks on the stack. To check for letter characters in the input string, you can cast the character you extract from the input string to an int to get its ASCII value. Then you can check if its ASCII value lies between 97 (lower case 'a') and 122 (lower case 'z'). 4. When the string ends, pop the entire stack and store it in another string. This is the reverse string of what you input. 5. Compare the letters (only) of the input string and the reversed string you generated in step 3 above. If they are equal, the input string is a palindrome. 6. Print if the string is a palindrome or not. Some sample inputs are shown below: Enter a string to test for palindrome: Tuna roll or a nut? Reverse string is: tunarolloranut Input string is a palindrome

Enter a string to test for palindrome: Race fast safe car! Reverse string is: racefastsafecar Input string is a palindrome

Enter a string to test for palindrome: Race car. Reverse string is: racecar Input string is a palindrome.

Enter a string to test for palindrome: Fast car. Reverse string is: cartsaf Input string is not a palindrome.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!