i have code using method yet i could not make it work.. Can someone help me.. Thank you.

package scsiaug10;
import java.io.*;
public class Main {

    public static void main(String args[])throws IOException{
        BufferedReader read = new BufferedReader(new InputStreamReader(System.in));
        System.out.print("Enter a Word:");
        String s = read.readLine();
        char c[] = new char[s.length()];
        for(int i=0; i<s.length(); i++){
            c[i] = s.charAt(i);
        }
        display(c); // Create a method to display the content of array c
        System.out.println();
        if(palin(c));
                 // create a method that will return true if the content of array passed to it is palindrome otherwise, return false
   {
     System.out.println("String "+s + " is palindrome");
else
     System.out.println("String "+s + " is NOT a palindrome");
}
reverse(c); // create a method that will reverse the content of char array c
    display(c);
}



public static void display(char A[] ){
for(int i=0;i<A.length;i++){
System.out.print(A[i]);
}
}

public static boolean palin (char A []){
for(int i=0;i<A.length;i++){
System.out.print(A[i]);

        boolean x=true;
        for(int t=0; t<(A.length/2); t++){
            if(A[i]!=A[A.length-i-1])
               x=false;
    }
        return(x);
    }
    }

public static void display(char A[] ){
for(int i=0;i<A.length;i++){
System.out.print(A[i]);

  int temp;
    for ( int j=0; j <A.length/2 ; j++){
        temp = A[j];
        A[j] = A[A.length-1-j];
        A[A.length-1-j] = temp;
    }
    for ( int j=0; j < A.length; j++){
        System.out.print(data[j]+", ");
    }
}



}}

Recommended Answers

All 2 Replies

1.Please use the "Code" tag next time...
2.What is your error? What does it say?
3.You declare "display()" method twice?

c

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.