Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- /**
- Reads a string, checks to see if it is a palindrome, and prints
- "Yes" or "No", accordingly.
- Input: the value of s, a string
- Output: "Yes" or "No"
- */
- public class PalFind
- {
- public static void main(String[] args)
- {
- // Read string and convert to lowercase
- Scanner in = new Scanner(System.in);
- String ins = in.nextLine();
- ins = ins.toLowerCase();
- for(int i = 0; i < ins.length()/2; i++)
- {
- if(ins.charAt(i) != ins.charAt(ins.length() - 1 - i))
- {
- System.out.println("No");
- return;
- }
- }
- System.out.println("Yes");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment