Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please help me with this C++ lab. Palindromes are sequences that are identical when traversed both forwards and backwards. Words can be palindromes, such as

Please help me with this C++ lab.

Palindromes are sequences that are identical when traversed both forwards and backwards. Words can be palindromes, such as refer and racecar, as well as number such as 12321 and 8675768. Palindromes aren't limited to just words and numbers: Sentences can be palindromes as well, such as Mr. Owl ate my metal worm (note that in this context, non-alphanumeric characters are skipped when traversing the string forwards and backwards). The concept of palindromes also exists in the fields of number theory, genetics, and music theory.

Specifications

In this lab, you will write a program that determines whether or not a string of alphanumeric characters is a palindrome. Ignore any whitespace characters or punctuation when processing the string. You will be required to demonstrate pointer math and dereferencing for this lab (30 pts). The algorithm to determine whether a string is a palindrome will have this header:

bool isPalindrome(const char* input, int size) (5 pts) You will be required to separate your interface from your implementation as demonstrated in class (5 pts); you must have a header file (.h) for your interface, and a source file (.cpp) for your implementation. Submit both for grading.

Be sure to perform data validation on your input to prevent buffer overflows (5 pts).

Sample output

Your code should present the user with prompts similar to the following (5 pts):

image text in transcribed

Here are some example palindromes you can test with:

Mr. Owl ate my metal worm Do geese see God? Was it a car or a cat I saw? Murder for a jar of red rum A nut for a jar of tuna Go hang a salami, I'm a lasagna hog!

PreviousNext

Enter string to test, 50 chars max, ctrl-C to end: Mr. Owl ate my metal worm The string "Mr. Owl ate my metal worm" is a palindrome! Enter string to test, 50 chars max, ctrl-C to end: 123454321 The string " 123454321 " is a palindrome! Enter string to test, 50 chars max, ctrl-C to end: I think, therefore I am The string "I think, therefore I am" is NOT a palindrome! Enter string to test, 50 chars max, ctrl-C to end

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

Step: 3

blur-text-image

Ace Your Homework with AI

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

Get Started

Students also viewed these Databases questions