Advertisement
Guest User

Untitled

a guest
Apr 1st, 2015
221
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.78 KB | None | 0 0
  1. public class Palindrome {
  2. static String ss;
  3. int x = 0;
  4. static char first = ss.charAt(0);
  5. static char last = ss.charAt(ss.length());
  6. static int length;
  7.  
  8. public static void main(String[] args) {
  9. System.out.println("Enter a word or phrase, to test whether it is a palindrome: ");
  10. Scanner keyboard = new Scanner(System.in);;
  11. String s = keyboard.nextLine();
  12. String ss = s.toLowerCase();
  13.  
  14. if (isPalindrome){
  15. System.out.println("\"" s "\" is a palindrome.");
  16. }
  17. else{
  18. System.out.println("\"" s "\" is not a palindrome.");
  19. }
  20. }
  21.  
  22.  
  23. public static boolean isPalindrome(String ss) {
  24. length = ss.length();
  25. int x = 0;
  26. ss.substring (x, ss.length()-x);
  27.  
  28. if (first == last){
  29. x++;
  30. return true;
  31. }
  32. else
  33. {
  34. return false;
  35. }
  36.  
  37. }
  38.  
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement