Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package lab5;
- import java.util.Scanner;
- public class task2 {
- public static boolean isPalidrome(String arg) {
- int lenth =arg.length();
- int n=0;
- for(int i=0; i<lenth/2;i++) {
- if(arg.charAt(i)==arg.charAt((lenth-1)-i))
- n=1;
- }
- if(n==1)
- return true;
- else
- return false;
- }
- public static void main(String[] args) {
- Scanner ac = new Scanner(System.in);
- System.out.println("enter any word");
- String word=ac.nextLine();
- if(isPalidrome(word)) {
- System.out.println( word+ " is Palidrome");
- }
- else
- System.out.println( word+ " is not Palidrome");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement