Program To Print Lead Number JAVA


Write a Program to print whether the inputted number is Lead or not.




[In a given number if the sum of even digits is equal to the sum of odd digits such numbers are called lead numbers.]


import java.util.*;
class leadnumber
{
    public static void main(String args[])
    {
     Scanner sc = new Scanner (System.in);
     int n = sc.nextInt();
     int sum_even=0,sum_odd=0;
     while (n>0)
     {
         int d = n % 10;
         if(d%2==0)
         {
             sum_even=sum_even+d;
         }
         else
         {
           sum_odd=sum_odd+d;   
         }
         n=n/10;
     }
     if(sum_even==sum_odd)
     {
         System.out.println("It is a lead number");
     }
     else
     {
         System.out.println("It is not a lead number");
     }
   }
}

     
                     

Contact Us

REACH US

SERVICES

  • CODING
  • ON-LINE PREPARATION
  • JAVA & PYTHON

ADDRESS

B-54, Krishna Bhawan, Parag Narain Road, Near Butler Palace Colony Lucknow
Contact:+ 919839520987
Email:info@alexsir.com