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
Note : The program is written in the easiest way possible so try to understand it. If you face any problem in understanding this program than feel free to contact/comment.
Source Code : Click here
Program Video : Watch now
All the Best :)
Keep Learning :)
Comments