In this section, we will learn what is a lead number and also create Java programs to check if the given number is a lead number or not. The lead number program frequently asked in Java coding tests and academics.

In a given number if the sum of even digits is equal to the sum of odd digits such numbers are called lead numbers. Let's take the number 1452 and check it is a lead number or not.

Even digits are: 4, 2

The sum of even digits = 4 + 2 =6

Odd digits are: 1, 5

The sum of odd digits = 1 + 5 =6

We observe that the sum of even digits is equal to the sum of odd digits. Hence, the given number 1452 is a lead number.

Similarly, we can check other numbers also.

Number Even Digits Sum of Even Digits Odd Digits Sum of Odd Digits Comparing Sum Lead or Not
1568723 6, 8, 2 16 1, 5, 3, 7 16 16=16 Lead
6732 6, 2 8 7, 3 10 8≠10 Not Lead
1372 2 2 1, 3, 7 11 2≠11 Not Lead
29041 2, 4, 0 6 9, 1 10 6≠10 Not Lead
6369 6, 6 12 3, 9 12 12≠12 Lead

## Steps to Check Lead Number

1. Read or initialize an integer N.
2. Find the last digit (x) of the number N by using the modulo (%) operator.
3. Divide the number by 10. It removes the last digit.
4. Check if the digit (x) is even or odd.
• If the digit is even added it to a variable evenSum.
• If the digit is odd added it to a variable oddSum.
5. Compare the even and odd sum.
• If the sum is equal, the number N is a lead number.
• If the sum is not equal, the number N is not a lead number.

Let's implement the above logic in a Java example.

### Using Function

Output 1:

```Enter a number: 29041
```

Output 2:

```Enter a number: 1372
```

Let's see another logic for the same.

### Using if-else Statement

Output 1:

```Enter the number: 27698
```

Output 2:

```Enter the number: 2436876
2436876 is not a Lead number.
```

### Feedback   