/*
Write a program to accept a number and check it is a lead number or not.
Lead number is a number in which the sum of the even digits is equal to the sum of the odd digits.
Example- 1452
4+2=6
1+5=6
6==6
so, 1452 is a lead number.*/
import java.util.*;
class lead_no
{
public static void main(String[]args)
{
Scanner sc=new Scanner(System.in);
System.out.println("Enter a number:");
int n=sc.nextInt();
int k=n,r,se=0,so=0;
while(n>0)
{
r=n%10;
if(r%2==0)
se=se+r;
else
so=so+r;
n=n/10;
}
if(se==so)
System.out.println(k+" is a Lead Number");
else
System.out.println(k+" is not a Lead Number");
}
}
No comments:
Post a Comment
any problem in any program comment:-