Given a starting number and the ending number the task is to find the all the Evon Number present in that given range and also to display it’s frequency.
Evon Number is a number whose number of digits is equal to the number of even digits.
Example 1: 2462 has four digits and four even digits. Hence it is an Evon Number.
Example 2: 1441 has four digits but two even digits. Hence it is not an Evon Number.
Java
import java.util.*;
public class EvonNumberRange
{
public static void main(String args[])
{
int start=0,end=0,r=0,flag=0,temp=0,count=0,frequency=0;
Scanner sc=new Scanner(System.in);
System.out.print("Enter a starting range: ");
start=sc.nextInt();
System.out.print("Enter a ending range: ");
end=sc.nextInt();
System.out.println("Evon Numbers in the given range are:-");
for(int i=start;i<=end;i++)
{
temp=i;
while(temp>0)
{
r=temp%10;
if(r%2==0)
{
flag++;
}
count++;
temp=temp/10;
}
if(flag==count)
{
System.out.println(i);
frequency++;
}
flag=0;count=0;
}
System.out.println("Frequency: "+frequency);
}
}Java