Question
write a program in C++. STACK and QUEUE ADT (TEMPLATES)Project: Project: Word-By-Word Palindromes. A word-by word palindrome is a string of words such that the
write a program in C++.
STACK and QUEUE ADT (TEMPLATES)Project:
Project: Word-By-Word Palindromes. A word-by word palindrome is a string of words such that the words read the same forward and backward. For example, the quote "abba aba" is a word level palindrome because it takes each word and makes sure it's the same forward as it is backward. Write a program to test input strings and tell whether or not they are word-by-word palindromes or not. Consider upper- and lowercase letters to be the same letter and have the program only consider letters and not symbols.
I have code so far where it tests the whole line to see if it's a palindrome or not. What I really want is to test each WORD and see if each INDIVIDUAL WORD is a palindrome. Somehow the program needs to look at the whitespace and check in between each whitespace whether the word is a palindrome or not. PLEASE HELP! WILL RATE!!! C++
Code:
// FILE: pal.cpp
// Program to test whether an input line is a palindrome. Spaces,
// punctuation, and the difference between upper- and lowercase are ignored.
#include
#include
#include
#include
#include
using namespace std;
int main()
{
queue
stack
char letter;
queue
cout
while (cin.peek() != ' ')
{
cin >> letter;
if (isalpha(letter))
{
q.push(toupper(letter));
s.push(toupper(letter));
}
}
while ((!q.empty()) && (!s.empty()))
{
if (q.front() != s.top())
++mismatches;
q.pop();
s.pop();
}
if (mismatches == 0)
cout
else
cout
cin.ignore(2);
return 0;
}
Once again this is the code I have so far. What I want it to do is test each word the user inputs not the whole line!!! Here are some sample outputs!!
Please use the code above including queues and stacks to get these outputs!
PA203-01 Programming Exercises PE21DebuglPE2.exe Enter a line and I will see if it's a word-level palindrome Able was I ere I saw Elba That is not a word-level palindrome
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started