Write a program using stacks that tests whether or not a word, expression or number is a palindrome. A palindrome is a word or expression that reads the same forwards and backwards. (ignore punctuation and blanks) Test at least 10 phrases and words.

Be sure to label any palindromes as numeric or string in the output.

Examples of palindromes:

radar
Able was I ere I saw Elba
Madam I’m Adam
racecar
1991
2002
A Toyota’s a Toyota.

In a container of candies there are 5 colors randomly placed: red, yellow, green blue and white. Assume that the container holds a maximum of 15 candies. Use a stack program to simulate randomly placing some (between 5 and 12 candies) initially into the container (stack).

Now once that is done have the "user" choose a color and using ONLY stack functions remove all candies of that color. All candies in the container (stack) that are NOT of that color are returned to the candy in the same order they were in prior to the color removal. Actually loop the program twice to simulate "filling" and "removing" two sets of candies. Don't assume that there are necessarily all colors of candy all the time...so for example someone might want all red candies but there might not be any red candies at that time.

Fill the container (or partially fill) only ONCE for each run. Here is an example: Suppose you place candies in this order: R R Y B G R B Y B G Y R B W B G Then the stack would look like this:

R
R
Y
B
G
R
B
Y
B
G
Y
R
B
W
B
G (top of stack)

If you asked to remove all green the resulting stack would be:

R
R
Y
B
R
B
Y
B
Y
R
B
W
B(top of stack)
Academic Honesty!
It is not our intention to break the school's academic policy. Posted solutions are meant to be used as a reference and should not be submitted as is. We are not held liable for any misuse of the solutions. Please see the frequently asked questions page for further questions and inquiries.
Kindly complete the form. Please provide a valid email address and we will get back to you within 24 hours. Payment is through PayPal, Buy me a Coffee or Cryptocurrency. We are a nonprofit organization however we need funds to keep this organization operating and to be able to complete our research and development projects.