L11a

Due by the end of this meeting

Starter Files:


SUBMIT   /   Submission Summary

Stacks

Activity
Create a program named PalindromeChecker based on the program BalanceChecker (provided).

A string is a palindrome if its letters read the same forwards or backwards. For example, the letters of "Race car" are RACECAR, and if you reverse those letters it comes out the same (RACECAR), so it is a palindrome. On the other hand, "Fred Nerf" has the letters FREDNERF, which reverse to FRENDERF, which is not the same. Thus "Fred Nerf" is not a palindrome.

One way to check if a String is a palindrome is to put all its letters into a stack. Then go thru the String again, and for each letter check whether it matches the one you pop off the stack. If you ever get a mismatch, the String is not a palindrome. If you get all the way thru without a mismatch, the String is a palindrome.

Use the code
Character.isLetter(nextLetter)
to check if nextCharacter is a letter.

Test your code on the following palindromes:

Also check the following non-palindromes:
Your grade will be based on the following rubric:

Submit this/these files:


SUBMIT   /   Submission Summary