Problem: Write a java program to check whether a number is a Buzz number or not.

Example:

Input:   777
Output:  Buzz Number

Input:   123
Output:  Not a Buzz Number

Any number that ends with 7 or is divisible by 7 is called a buzz number.

For example, 127 ends with 7, so it is a Buzz number. Also, 343 is buzz because it is divisible by 7.

Here is the Java program that check whether the input number is buzz or not.

import java.util.Scanner;
 
public class Main
{
	public static void main(String[] args) {
	    Scanner in=new Scanner(System.in);
	    
		System.out.println("Enter a number");
		int num = in.nextInt();
		
		if(num%7==0 || num%10==0){
		    System.out.println("Buzz Number");
		} else {
		    System.out.println("Not a Buzz Number");
		}
	}
}

Output:

Enter a number
35
Buzz Number

Leave a Reply