Google News
logo
Java Program to Buzz Number
A Buzz number is a positive integer that is either divisible by 7 or has its last digit as 7. Here is the Java program to check if a given number is a Buzz number or not :
Program :
import java.util.Scanner;

public class BuzzNumber {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        System.out.print("Enter a number: ");
        int num = scanner.nextInt();

        if (num % 7 == 0 || num % 10 == 7) {
            System.out.println(num + " is a Buzz number");
        } else {
            System.out.println(num + " is not a Buzz number");
        }
    }
}
Output :
Enter a number: 7
7 is a Buzz number
Enter a number: 11
11 is not a Buzz number
In this program, we first ask the user to enter a number. Then, we use the modulus operator to check if the number is divisible by 7 or if its last digit is 7.

If either of these conditions is true, we print that the number is a Buzz number. Otherwise, we print that the number is not a Buzz number.