Dremendo Tag Line

Check buzz number in Java

if else - Question 10

In this question, we will see how to check if a number is a buzz number or not in Java programming using the if else statement. To know more about if else statement click on the if else statement lesson.

Q10) Write a program in Java to input a number and check if it is a buzz number or not. A number is a buzz number if it is divisible by 7 or if its last digit is 7. Make use of logical operator || to solve this question.


import java.util.Scanner;

public class Q10
    public static void main(String args[])
        int n;
        Scanner sc=new Scanner(System.in);
        System.out.print("Enter a number ");
        if(n%7==0 || n%10==7)
            System.out.print("Buzz number");
            System.out.print("Not a buzz number");


Enter a number 21
Buzz number