Buzz Number in JAVA

Buzz Number

Buzz Number - A number is said to be Buzz Number if it ends with 7 or is divisible by 7.

Example : Input    : 307
                 Output  : It is a Buzz Number

                 Input    : 63
                 Output  : It is a Buzz Number

                 Input    : 52
                 Output  : It is not a Buzz Number

Algorithm and Program given below :-

Algorithm :- 

  • Input a number
  • Using if statement check if it is divisible by 7
  • Or if it ends with 7
  • If condition satisfies display "It is a Buzz Number"
  • Else display "It is not a Buzz Number"

Program :-

import java.io.*;
import java.util.*;
class Buzz
{
    public static void main(String args[])
    {
        Scanner in = new Scanner(System.in);
        int n;
        System.out.println("Enter Number ");
        n= in.nextInt();
// Input Number
        if(n%10==7||n%7==0)
//if the number has 7 at the last position or it is divisible by 7
        {
            System.out.println("It is a Buzz Number : "+n);
        }
        else
        {
            System.out.println("It is not a Buzz Number : "+n);
        }
    }
// end of main method
}
// end of class 


All the Best :)
Keep Learning :)

Watch Video : https://youtu.be/EzQ9mt2OLqQ



Comments

Popular posts from this blog

Frequency of each digit of a number in Java

Trimorphic Number in JAVA

PalPrime Number in JAVA