KAKAN

det

Jan 10th, 2017
207
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.83 KB | None | 0 0
  1. import java.util.Scanner;
  2. public class specialpalin
  3. {
  4.     static Scanner key = new Scanner(System.in);
  5.     public static void main(String ar[])
  6.     {
  7.         System.out.print("Enter a word: ");
  8.         String test = key.next();
  9.         if(palindromeCheck(test)) System.out.println("Is a palindrome!");
  10.         else System.out.println("Not a palindrome!");
  11.         if(specialCheck(test)) System.out.println("Is a special word!");
  12.         else System.out.println("Not a special word!");
  13.     }
  14.     public static boolean palindromeCheck(String s)
  15.     {
  16.         StringBuffer obj = new StringBuffer(s);
  17.         if(s.equals(obj.reverse().toString())) return true;
  18.         else return false;
  19.     }
  20.     public static boolean specialCheck(String s)
  21.     {
  22.         String a = String.valueOf(s.charAt(0));
  23.         String b = String.valueOf(s.charAt((s.length()-1)));
  24.         if(a.equalsIgnoreCase(b)) return true;
  25.         else return false;
  26.     }
  27. }
Add Comment
Please, Sign In to add comment