0
import java.util.Scanner;
public class Homework
{
    static String aString;
    public Homework()
    {

    }

    public static void Check(String args[])
    {
        Scanner s = new Scanner(System.in);
        aString=s.next();
        boolean palinder;
        palinder=true;
            for(int i=0;i!=aString.length()/2;i++)
          {
            if (aString.charAt(i)!=aString.charAt(aString.length()))
                {
                   System.out.println("The word "+aString+" isn't a palinder");
                   palinder=false;
                }
          }
        if (palinder)
        {
            System.out.println("The word "+aString+" is a  palinder");
        }
    }
}

I wrote this program which is supposed to determine whether a word is a palinder or not, but the problem is that when I launch it in blueJ the program won't load, its like I looped. I can't figure out what did I write wrong.

Santosh Panda
  • 7,235
  • 8
  • 43
  • 56

1 Answers1

0

Here is the solution. You need to change your current code significantly.

import java.util.Scanner;

public class Homework
{
public Scanner s;
public String wordToTest;

public void HomeWork()
{
    s = new Scanner(System.in);
    wordToTest = s.next();

    Check(wordToTest);
}

public static void Check(String testWord)
{
    String aWord = "palinder";

    if (aWord.equals(testWord))
    {
        System.out.println("The word "+testWord+" is a  palinder");
    }
    else
    {
        System.out.println("The word "+testWord+" isn't a palinder");
    }

}
}

Hope it will help.

VD007
  • 267
  • 2
  • 15