0

I am making a palindrome calculator. Here is my code

class test{
public static void main(String args[])
{
    String word="";
    String test="";
    int left = 0;
    int leftt = 1;

    while(!word.equals("END")){
        word = BIO.getString();                 
        test = word;
        {
            String wordLC = word.toLowerCase();
            int rightt = wordLC.length()-2;
            int right = wordLC.length()-1;
            {
                if(word == "END"){
                    break;
                }       
                else if(word.charAt(left) == word.charAt(right) && word.charAt(leftt) == word.charAt(rightt)){
                System.out.printf("%-10s is a palindrome",word);

                }else{
                System.out.printf("%-10s is not a palindrome",word);
                }
            }
        }
}

} }

I want to make it that when the word 'END' is put in, everything is shut down. I've tried to do this with the while and the if statement within the while.

The word END does end the loop, however it will carry on to state : "END is not a palindrome".

where as I just want the loop to end.

Thanks

sofia8991
  • 1
  • 1

0 Answers0