// FInished isPal but need help with other few.

public class Lab14st
   {
public static void main (String args[])
   {
    System.out.println("Lab 14, 80 Point Version");
    System.out.println();
    System.out.println("The Palindrome Program");
    System.out.println();
    System.out.println("By: Arjun Desai");  // Substitute your own name here.
    System.out.println("\n===========================\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));
        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.
 */
{

  if(s.length() == 0 || s.length() == 1)

        return true; 

  if(s.charAt(0) == s.charAt(s.length()-1))

        return isPal(s.substring(1, s.length()-1));

          return false;
}

public static String purge(String s)
/*
 * Precondition:  s is an arbitrary String.
 * Postcondition: All non-letter characters are removed from s, and this new "purged" String is returned.
 */
{

    return s;
}

public static boolean almostPal(String s)
/*
 * Precondition:  s is an arbitrary String.
 * Postcondition: After purging all non-letter characters from s,
 *                the value of true is returned if the resulting String is a Palindrome, false otherwise.
 */
{
    return isPal(purge(s));   // Do not alter this method!
}

public static String leastPal(String s)
/*
 * Precondition:  s is an arbitrary String.
 * Postcondition: A new String is returned which is created by adding the minimum number of characters
 *                necessary to S to make it a Palindrome.
 */
{

    return "";
}
}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.