Saturday, November 6, 2021

Palindrome Number in Java

 A simple program to ask the user to give a number and then the program check if the given number is a palindrome or not a palindrome using Java programming language.

  I am currently accepting programming work, IT projects, school and application development, programming projects, thesis and capstone projects, IT consulting work, computer tutorials, and web development work kindly contact me at the following email address for further details.  If you want to advertise on my website kindly contact me also in my email address also. Thank you.

My email address is the following jakerpomperada@gmail.com, jakerpomperada@aol.com, and jakerpomperada@yahoo.com.

My mobile number here in the Philippines is 09173084360.






Program Listing

package test;

import java.util.Scanner;

public class Palindrome_Number {
	
	public static void main(String args[]) 
	{
	
	
	Scanner input=new Scanner(System.in);
	
	System.out.println();
    System.out.println("\tPalindrome Number in Java");
    System.out.println();
   
	System.out.print("\tGive a Number : ");
		
	int num=input.nextInt();
    int r,sum=0;
    int temp=num;    
    while(num>0)
    {    
    r=num%10;    
    sum=(sum*10)+r;    
    num=num/10;    
    }    
	
	
	System.out.println("\n");
	if(temp==sum)
	{
	System.out.println("\tThe given number " + temp + " is a Palindrome.");
	}
	else
	{
		System.out.println("\tThe given number " + temp + " is Not a Palindrome.");
	}
	 System.out.println();
     System.out.print("\tEnd of Program \n");  
     System.out.println();
	input.close();
}

}


No comments:

Post a Comment