Buzz Number
Buzz number:
A number is said to be Buzz Number if it ends with 7 or is divisible by 7.
/* Java program to check given number is buzz number or not*/
package rakesh;
import java.io.*;
class BuzzNumber
{
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
int a;
public void show() throws Exception
{
System.out.print("Enter the number:");
a = Integer.parseInt(br.readLine());
if( a % 10 == 7 || a % 7 == 0 )
System.out.println("Entered number is a Buzz number.");
else
System.out.println("Entered number is not a Buzz number.");
}
public static void main(String args[]) throws Exception
{
BuzzNumber bn=new BuzzNumber();
bn.show();
}
}
OUTPUT:
Enter the number:49
Entered number is a Buzz number.
Enter the number:23
Entered number is not a Buzz number.
A number is said to be Buzz Number if it ends with 7 or is divisible by 7.
Example:
1007 is a Buzz Number as it end with 7.343 is also a Buzz Number as it is divisible by 7 and 77777 is also a Buzz Number as it ends with 7 and also it is divisible by 7.
/* Java program to check given number is buzz number or not*/
package rakesh;
import java.io.*;
class BuzzNumber
{
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
int a;
public void show() throws Exception
{
System.out.print("Enter the number:");
a = Integer.parseInt(br.readLine());
if( a % 10 == 7 || a % 7 == 0 )
System.out.println("Entered number is a Buzz number.");
else
System.out.println("Entered number is not a Buzz number.");
}
public static void main(String args[]) throws Exception
{
BuzzNumber bn=new BuzzNumber();
bn.show();
}
}
OUTPUT:
Enter the number:49
Entered number is a Buzz number.
Enter the number:23
Entered number is not a Buzz number.
No comments:
Post a Comment