So I've been assigned the following problem and I don't even know where to start. Is he wanting the palindrome's pulled from an array? All of the research I've done online about palindrome's, none of them use boolean values. Thanks in advance. Programming isn't my forte to say the least.
Problem 2.1. (5 points) Write a program that accepts a string of characters terminated by a period and determines whether the string (without the period) is a palindrome. Assume that the input contains only letters and blanks. Assume also that the input is at most 30 characters long. Disregard blanks when deciding if a string is a palindrome and consider upper and lower case version of the same letter to be equivalent. Provide a static method palindrome
public static boolean palindrome(char[] a, int number)
that accepts a char array containing the characters of the input string, and an integer defining the number of characters in the string.
What he wants you to do is find out whether the sequence of characters in the array is a palindrome. You don't need to return any information about it. If you are still stuck, here are some tips:
String
s that char[]
s. Try creating a string out of the array and using that in your computations.It may seem that the number parameter is redundant, but I would be safe and construct the string like this:
new String(a, 0, number)