I am working on a program that would allow a user to input a phrase (with letters and spaces) and let them know whether or not it's a palindrome.
Here's my progress thus far:
I am trying to start a new method isPalindrome that will be responsible for creating an array with no spaces and then comparing characters to test if the phrase is a palindrome. What I don't quite understand are the parameters for this method. I keep getting an error that says an identifier is expected. Can someone help?
What I don't quite understand are the parameters for this method.
The way you are starting your method definition is incorrect. The method must have been written in this manner
Now you pass your String variable (i.e. the variable which has the actual contents from the user) in your case it is "phrase" to the method parameter "checkString" and then do
your operation on checkString. You can call the method in this manner
Note you can use any name in place of "checkString" i.e. you can even use "phrase" but to avoid any confusion i just changed the name.
I have added code tags to your post, and you can see how much better it looks. Always use spaces, not tabs, for indenting.
You are going about this the wrong way. You should divide your work into smaller pieces, like this:
1: Remove spaces from string
2: Convert to consistent case
3: Check whether palindrome
You can make those all methods of a utility class.
You should work out with paper pencil and eraser (the latter is the most important piece of hardware) how you intend to do it. Write out a String like this on paper:
Get rid of the spaces
Work out how you can tell whether it is or is not a palindrome.