From a7df75d88bd67b35af70d6692f1eea4460a0898a Mon Sep 17 00:00:00 2001 From: Ankit-5087 <85407190+Ankit-5087@users.noreply.github.com> Date: Tue, 5 Oct 2021 17:44:19 +0530 Subject: [PATCH] Create palindrome.java java based program to find if the given data is a palindrome or not. --- palindrome.java | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 palindrome.java diff --git a/palindrome.java b/palindrome.java new file mode 100644 index 0000000..aef84cd --- /dev/null +++ b/palindrome.java @@ -0,0 +1,26 @@ +/ Contributor Info : +// Name : Ankit Raj +// Git : https://github.com/Ankit-5087 + +import java.util.*; +class palindrome +{ + public static void main(String args[]) + { + Scanner sc=new Scanner(System.in); + System.out.println("Please enter a no."); + int num=sc.nextInt(); + int temp=num,digit,sum=0; + + while(num>0) + { + digit=num%10; + sum=sum*10+digit; + num=num/10; + } + if(temp==sum) + System.out.println("Palindrome no."); + else + System.out.println("Not a palindrome no."); + } +}