Given a starting number and the ending number the task is to find the all the Buzz Number present in that given range and also to display it’s frequency.
Buzz Number is a number which ends with digit 7 or is divisible by 7.
Example 1: 42 is divisible by 7. Hence it is a Buzz Number.
Example 2: 107 ends with 7. Hence it is a Buzz Number.
Java
import java.util.*;
public class BuzzNumberRange
{
public static void main(String args[])
{
int start=0,end=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("Buzz Numbers in the given range are:-");
for(int i=start;i<=end;i++)
{
if((i%10)==7||(i%7)==0)
{
System.out.println(i);
frequency++;
}
}
System.out.println("Frequency: "+frequency);
}
}
Java