import java.io.*;
import java.util.*;
public class Palindrome {
public static void main(String[] args) throws IOException {
char letter;
String reversed,NEW;
Stack S = new Stack();
BufferedReader stndin=new BufferedReader(new InputStreamReader(System.in));
System.out.print("Enter a word: ");
String word=stndin.readLine();
for(int i=0; i<word.length(); i++){
letter = word.charAt(i); //this line should cut the 1st letter of the word (but im not sure with this process)
S.push(letter); //then push that letter to the stack
}
for(int i=0; i<word.length(); i++){
NEW = S.pop(); //the problem goes here with ERROR:incompatble types
CONCAT(reversed,NEW); //ERROR:cannot find symbol method CONCAT(java.lang.String,java.lang.String)
}
if(reversed.equals(word)){
System.out.println("Palidrome!");
}
else System.out.println("Not Palidrome!");
}
}
barbz 0 Newbie Poster
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.