Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Description: You are going to write a program that checks to see if a string is a palindrome. A palindrome is a word, phrase, number,

Description: You are going to write a program that checks to see if a string is a palindrome. A palindrome is a word, phrase, number, or other sequence of characters which reads the same backward as forward, such as madam or race car. Sentencelength palindromes may be written when allowances are made for adjustments of capital letters, punctuation, or word dividers, such as A man, a plan, a canal Panama!. (Wikipedia) You will use a stack and a queue to determine if a phrase is a palindrome. You will ignore spaces and punctuation. You may use either a c-string or a c++ string. (Hint: You should store characters on the stack and queue to make this easy.)

The stack class is written for you, but will need to be modified to use the correct type. You will need to write the queue class. The Node class will need to be modified to work with the stack and queue classes.

The code to check to see if the string is a palindrome should be in the main function. You should have 2 test cases that you test in main one that is palindrome and one that isnt. Then you should ask the user for a phrase until the user wishes to terminate.

Specific information for classes:

Stack class data

top points to first Node in list

count keeps track of number of Nodes in list

Stack class functions

Any needed constructors

push adds a Node to the top of the stack

pop Removes a Node from the top of the stack

stack_top Returns the item at the top of the stack without affecting the stack

empty returns true if stack is empty, false otherwise

Note: Remember that a stack is created in static (automatic memory) and a Node is in dynamic memory.

Queue class data

front points to first Node in list

rear points to the last Node in list

count keeps track of number of Nodes in list Stack class functions

Any needed constructors enqueue adds a Node to the end of the list

dequeue Removes a Node from the front of the queue

get_front Returns the item at the front of the queue without affecting the queue

empty returns true if queue is empty, false otherwise

Note: Remember that a queue is created in static (automatic memory) and a Node is in dynamic memory.

There is pseudo code written for the queue class and available under Notes on Blackboard.

Requirements for main: In the main program, you will test 2 cases; one that is a palindrome and one that isnt. Then you will ask the user for a phrase and indicate whether or not the phrase is a palindrome. You will loop until the user wishes to exit.

Sample:

The phrase race car is a palindrome.

The phrase man made is not a palindrome.

Please enter a phrase: Madam Madam is a palindrome.

Reminder:

Be sure to turn in 6 separate files.

Your file names will be makefile, main.cpp, node.cpp, node.hpp, stack.cpp, stack.hpp, queue.hpp, and queue.cpp .

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Spomenik Monument Database

Authors: Donald Niebyl, FUEL, Damon Murray, Stephen Sorrell

1st Edition

0995745536, 978-0995745537

More Books

Students also viewed these Databases questions

Question

Describe a margin loan.

Answered: 1 week ago

Question

In Problem is the matrix game strictly determined? 5 -1 -3 2

Answered: 1 week ago

Question

2. Place a value on the outcomes.

Answered: 1 week ago