Plz

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • alhisnawy
    New Member
    • Feb 2010
    • 4

    Plz

    Q--------------
    Specify and implement a procedure that determines whether or not a string is a palindrome. (A palindrome reads the same backward and forward; an example is "deed.")
    --------------------------------
    Q------------------------------------------
    Implement a standalone procedure to read in a file containing words and white space and produce a compressed version of the file in an output hie. The compressed version should contain all of the words in the input file and none
  • anurag275125
    New Member
    • Aug 2009
    • 79

    #2
    Determine whether a string is palindrome or not.....

    import java.util.*;
    public class palindr
    {
    static Scanner sc=new Scanner(System. in);
    public static void main(String args[])
    {
    boolean result;
    System.out.prin tln("Enter String : ");
    String str=sc.nextLine ();
    result=palin(st r);
    if(result)
    System.out.prin tln("String is palindrome");
    else
    System.out.prin tln("String isn't palindrome");
    }
    static boolean palin(String str)
    {
    char[] c=str.toCharArr ay();
    String st="";
    int l=c.length;
    for(int i=l-1;i>=0;i--)
    st+=c[i];
    if(str.equals(s t))
    return true;
    else
    return false;
    }
    }

    Comment

    Working...