So this code is supposed to take an entered string, turn that string backward, then compare the original and backward string to see if they match and return true if they are palindromes. Before turning the text backward, I'm trying to convert it to lowercase, however I'm getting a "cannot find symbol" error on the line where I take the parameter passed to the method, convert it to lowercase, and store it in a new variable.
I have no idea what's causing this, from what I know about java(which isn't much), the "cannot find symbol" error while defining a variable within a method is often caused when the method or class cannot access whatever value is assigned to the new variable, however it seems to me like method isPal should have no problem being given the variable 'str'. Please, can someone tell me where I'm going wrong?
public class Lab14TEXT05st { public static void main (String args[]) { System.out.println("\nLab14TEST05\n"); boolean finished = false; do { System.out.print("Enter a string ===>> "); String str = Expo.enterString(); System.out.println(); System.out.println("Entered String: " + str); System.out.println("Palindrome: " + Palindrome.isPal(str)); <---This line should be passing string str to 's' in the isPal method System.out.println("Almost Palindrome: " + Palindrome.almostPal(str)); // used only for the 100 and 110 point versions System.out.println("Least Palindrome: " + Palindrome.leastPal(str)); // used only for the 110 point versions System.out.println(); System.out.print("Do you wish to repeat this program [Y/N]? ===>> "); char repeat = Expo.enterChar(); finished = (repeat != 'Y' && repeat != 'y'); System.out.println(); } while (!finished); } } class Palindrome { public static boolean isPal(String s) /* * Precondition: s is an arbitrary String. * Postcondition: The value of true is returned if s is a Palindrome, false otherwise. */ { String s2 = s.toLowerCase; <--The error message points to this line String s3 = ""; int n = s.length() - 1; for (int k = n; k >= 0; k--){ s3 += s2.charAt(k); } if (s2.equals(s3)){ return true; } }