# Buzz Number Program in Java

A number is said to be Buzz Number if it ends with 7 or is divisible by 7.  For example- 7, 17, 27, 37, 47 are buzz numbers because they end with 7. Similarly, the numbers 7, 14, 21, 28, 35, 49 are also buzz numbers because they are divisible by the number 7.

These are the following steps that we use to check whether the given number is a Buzz number or not.

1. We first take input from user.
2. We then find the last digit of the number and check whether it is equals to 7 or not. If it equals 7, print “the number is a Buzz” number.
3. We then find the remainder of the number with 7. If the remainder equal to 0, print “the number is a Buzz number“.
4. Else print “number is not a buzz number

## Java program to check whether given number is buzz number or not

Now  we will write a java program to check given number is buzz number or not . We take input from user and then check  buzz number or not using java program .

``````package com.demo.program;

import java.util.Scanner;

public class BuzzNumberProgram {

static boolean checkNumber(int number)
{
// check whether the number ends with 7, is divisible by 7 or not
if(number % 10 == 7 || number % 7 == 0)
return true;    //returns true when the number is Buzz
else
return false;   //returns flase when the number is not Buzz
}

public static void main(String[] args) {

int n;
//create scanner class object to get input from user
Scanner sc = new Scanner(System.in);
System.out.print("Enter number :");
//store user entered value into variable n
n = sc.nextInt();
if (checkNumber(n))
System.out.println(n + " is a Buzz number");
else
System.out.println(n + " is not a Buzz number");

}
}``````

Output :

``````Enter number :97
97 is a Buzz number``````

## Java program to find all buzz number in a given range

Now we will write java program to find all buzz number in given range .

``````package com.demo.program;

import java.util.Scanner;

public class BuzzNumbersRange {

public static void checkNumber(int number)
{
// check whether the number ends with 7, is divisible by 7 or not
if(number % 10 == 7 || number % 7 == 0) {
System.out.println(number + " is an Buzz number");
}

}

public static void main(String[] args) {
int range;
//create scanner class object to get input from user
Scanner sc = new Scanner(System.in);
System.out.print("Enter Range :");
range = sc.nextInt();
for(int i = 1; i <= range; i++)  {
checkNumber(i);
}

}

}``````

Output :

``````Enter Range :100
7 is an Buzz number
14 is an Buzz number
17 is an Buzz number
21 is an Buzz number
27 is an Buzz number
28 is an Buzz number
35 is an Buzz number
37 is an Buzz number
42 is an Buzz number
47 is an Buzz number
49 is an Buzz number
56 is an Buzz number
57 is an Buzz number
63 is an Buzz number
67 is an Buzz number
70 is an Buzz number
77 is an Buzz number
84 is an Buzz number
87 is an Buzz number
91 is an Buzz number
97 is an Buzz number
98 is an Buzz number``````

In this tutorial we have learned what is buzz number  and we have write java program to check buzz number . We also learned java program to find all buzz numbers in given range .