Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Create a new class named Palindrome Write a recursive method that takes a String and returns a boolean value indicating whether or not the String
- Create a new class named Palindrome
- Write a recursive method that takes a String and returns a boolean value indicating whether or not the String is a palindrome. Your program should ignore differences in capitalization, meaning "Racecar" should also be a palindrome. Define your method with the following header:
-
public static boolean isPalindrome(String str)
- Create a new class named PalindromeTest and write test cases that will thoroughly test your method.
- Implement the method. Keep in mind that an empty String and a String with one character are also palindromes. Null string is not.
- After you have finished writing your method, run your test class and fix any errors that you discover. Here are some palindromes to help you in your testing: racecar, deIfied, Hannah, Civic, spacecaps.
- Include these palindromes as test cases in your test class:
- Go hang a salami, I'm a lasagna hog.
- A Toyota! Race fast, safe car. A Toyota.
- "Tie Mandie," I'd name it.
- Wonton? Not now.
- Your tests will probably now fail. This is because something is still a palindrome if it contains symbols like: .,!?/\| space character, etc.
- Remove all such characters before checking to see if the argument is a palindrome. Reference the API for the Character class to find method(s) that may assist you. API links are at the top of this document.
- Numbers are not considered symbols. If your String is "1.2.1", the periods should be removed, with 121 being a palindrome.
- Run your tests again to make sure they pass.
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