0% found this document useful (0 votes)
2 views

Java4

The document contains a Java program that checks for palindrome numbers within a specified range. It prompts the user to enter a starting and ending number, then prints all palindrome numbers between those two values. The program includes a method to determine if a number is a palindrome by reversing its digits.

Uploaded by

121pratham2032
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

Java4

The document contains a Java program that checks for palindrome numbers within a specified range. It prompts the user to enter a starting and ending number, then prints all palindrome numbers between those two values. The program includes a method to determine if a number is a palindrome by reversing its digits.

Uploaded by

121pratham2032
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

3. Write a program to print palindrome number.

import java.u l.Scanner;

public class PalindromeNumber {

public sta c boolean isPalindrome(int num) {

int originalNum = num, reverse = 0, remainder;

while (num > 0) {

remainder = num % 10;

reverse = (reverse * 10) + remainder;

num /= 10;

return originalNum == reverse;

public sta c void main(String[] args) {

Scanner scanner = new Scanner(System.in);

System.out.print("Enter the star ng number: ");

int start = scanner.nextInt();

System.out.print("Enter the ending number: ");

int end = scanner.nextInt();

System.out.println("Palindrome numbers between " + start + " and " + end + " are:");

for (int i = start; i <= end; i++) {

if (isPalindrome(i)) {

System.out.print(i + " ");

scanner.close();

}
O/P: Enter the star ng number: 1

Enter the ending number: 121

Palindrome numbers between 1 and 121 are:

1 2 3 4 5 6 7 8 9 11 22 33 44 55 66 77 88 99 101 111 121

You might also like