Practical 7


Aim:- Write a program to find that given number or string is palindrome or not.

JAVA Code :-

import java.lang.*;
import java.io.*;
import java.util.*;

class pra7
{
  public static void main(String args[])
  {
     int len,i=0;
     String str=new String();
     Scanner s=new Scanner(System.in);

     System.out.print("Enter your string: ");
     str=s.nextLine();
    
     StringBuffer s1= new StringBuffer(str);
     s1.reverse();

     if(str.compareTo(s1.toString())==0)
            System.out.println("String is Pelindrom");
     else
           System.out.println("String is not Pelindrom");
  
  }
}


Output:-



No comments:

Post a Comment

Programs

Home Aim:- Write a program to convert rupees to dollar. (60rupees=1 dollar). Aim:- Write a program that calculate percentage marks...