CodeHub Menu
Home Exercise Practice About Download Portfolio Play Games NEW Privacy Policy Terms Contact
Login / Register

EvenPal number

JAVA November 18, 2025 5 views 0 likes
Define a class to accept a number from user and check if it is an EvenPal number or not. (The number is said to be EvenPal number when number is palindrome number (a number is palindrome if it is equal to its reverse) and sum of its digits is an even number.)
Example:
121 – is a palindrome number
Sum of the digits – 1+2+1 = 4
which is an even number.

Answer:-



EvenPal Number Program in Java

EvenPal Number Program in Java


import java.util.Scanner;

public class KboatEvenPal
{
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);

        System.out.print("Enter a number: ");
        int num = in.nextInt();
        int org = num;
        int rev = 0;
        int sum = 0;
        
        while (num > 0) {
            int d = num % 10;
            rev = rev * 10 + d;
            sum += d;
            num /= 10;
        }

        if (org == rev && sum % 2 == 0) {
            System.out.println(org + " is an EvenPal number.");
        } else {
            System.out.println(org + " is not an EvenPal number.");
        }
    }
}
5 views 0 likes
Total visits: 2,089 • Unique visitors: 1,285