daily pastebin goal
22%
SHARE
TWEET

Untitled

advictoriam Jan 11th, 2019 60 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import java.util.Scanner;
  2.  
  3. /**
  4.    Reads a string, checks to see if it is a palindrome, and prints
  5.       "Yes" or "No", accordingly.
  6.    Input: the value of s, a string
  7.    Output: "Yes" or "No"
  8. */
  9. public class PalFind
  10. {
  11.    public static void main(String[] args)
  12.    {
  13.       // Read string and convert to lowercase
  14.       Scanner in = new Scanner(System.in);
  15.       String ins = in.nextLine();
  16.       ins = ins.toLowerCase();
  17.       for(int i = 0; i < ins.length()/2; i++)
  18.       {
  19.          if(ins.charAt(i) != ins.charAt(ins.length() - 1 - i))
  20.          {
  21.             System.out.println("No");
  22.             return;
  23.          }
  24.       }
  25.       System.out.println("Yes");
  26.    }
  27. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand