I need a little bit of help with my coding below.

Whenever I try to run the second application it gives me

A man a plan a canal PanamaPalindromefalse
Hurray for HollywoodPalindromefalse
Mr Owl ate my metal wormPalindromefalse
Was it a car or a cat I sawPalindromefalse
Can I attain a CPalindromefalse

That's not what I want or am looking for, I am looking for ****

mom is a palindrome
dad is a palindrome
sister is not a palindrome
nevermind is not a palindrome

etc. etc.

Here's my code below to elaborate more on the issue.

Service class

    public class Palindrome

       private String pal;

        public Palindrome()
           pal = " ";

        public Palindrome(String newPal)

            pal = newPal.toUpperCase();


        public void setPal(String initPalin)
           pal = initPalin.toUpperCase();


        public String getPal()
           return pal;

        public boolean isPalindrome()
           int left = 0;
            int right = pal.length() -1;


              if (pal.charAt(left) != pal.charAt(right))
                     return false;

               return true;

         public String toString()

        return "Palindrome" + isPalindrome();

Client class ONE

import java.util.Scanner;

public class Palindromeclient
  public static void main(String[]args)

      boolean palin = false;

      Scanner scan = new Scanner(System.in);

      System.out.println("Enter statement: ");
      String userinput = scan.nextLine();

      Palindrome statement = new Palindrome(userinput);

      palin = statement.isPalindrome();

      System.out.println(userinput + " is a palindrome");
      System.out.println(userinput + " is not a palindrome");



Client Class Two

import java.util.Scanner;
import java.io.*;
public class Palindromeclient2
   Scanner scan = new Scanner(System.in);

   public static void main(String[] args)throws FileNotFoundException

   public static void Palindromeclient2() throws FileNotFoundException
       Palindrome statement = new Palindrome();

       File thefile = new File("myfile.dat");
        Scanner scan = new Scanner(thefile);

        while (scan.hasNext())
           String userinput = scan.nextLine();
            System.out.println(userinput + statement.toString());


Palindrome Class:

A palindrome is a word, phrase, or sentence that is symmetrical: that is, it is spelled the same forward and backward. Examples are “otto”, “mom”, and “Able was I ere I saw Elba”.
The Palindrome class should define a single String field. The class should define a isPalindrome method which returns true when the String is a Palindrome and false otherwise. Also define a method named toString which returns the String data member along with the result of the isPalindrome method is a readable format. For example,

Mom is a palindrome
Dad is a palindrome
Sister is not a palindrome

The isPalindrome method should conduct case-insensitive tests and spaces within the string should be ignored. Puncuation should not be entered.

Client Application1:
This client application is responsible for retrieving a word, phrase, or sentence from the user, and reporting whether or not the input given is a palindrome. The client should allow the user to test any number of strings.

Client Application2:
This client application is responsible for retrieving a filename from the user, and reporting whether each line of the input file is a palindrome or not. To test your application, create a text file containing multiple test cases (one per line.) Save the file in the same folder as the application class. Use a plain text editor such as Notepad or jGrasp to create the file. (In jGrasp, using the menu, select File | New | Other | Plain Text. After entering your test cases, select File | Save As and save with a file extension of .dat.) Below is an example text file:

A man a plan a canal Panama
Hurray for Hollywood
Mr Owl ate my metal worm
Was it a car or a cat I saw
Can I attain a C
6 Years
Discussion Span
Last Post by NormR1

Are you looking for a different formatting and contents for the program's output?
Instead of this: momPalindrometrue
you want this: Mom is a palindrome

Where is the current output generated? Find where the current output comes from and change it to output what you want to see.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.