Using the stack and queue class determine if a string is a


Using the stack and queue class, determine if a string is a palindrome. A palindrome is a string (empty to many sentences) that reads the same forwards and backwards. Some simple palindromes are: an empty string, "mom", "racecar", "madam, I'm Adam!!" Remove any punctuation or spaces from the inputted string before testing it as a palindrome.

In main, create a char stack and a char queue. Read in a string and push each character of the string on to the stack and into the queue (enqueue). Call a method (isPalindrome) to determine if the string is a palindrome, using the following algorithm: while neither structure is empty, pop a character from the stack and dequeue a character from the queue. Compare the two characters to see if they are unequal (if unequal, return false). At the end of the process when the stack and queue are empty, return true.

Run the program 3 times - once with "abca", once with "madam, I'm Adam!!", and once with a string of your choice.

 

Request for Solution File

Ask an Expert for Answer!!
Basic Computer Science: Using the stack and queue class determine if a string is a
Reference No:- TGS0645036

Expected delivery within 24 Hours