write a program to accept two numbers and check whether the product of two numbers is Buzz number or not.
no spam:(
Answers
import java .until.*;
public class Buzz_Number
{
public static void main (String [] args)
{
Scanner.sc=new Scanner (System.in);
int a,b,c;
System.out.println("Enter first number:");
a=in.nextInt();
System.out.println("Enter second number:");
b=in.nextInt();
c = a *b;
System.out.println("Product of two numbers is :" + c);
if((c/7 = = 0) || (c % 10 = = 7))
System.out.println("Product of two numbers is a buzz number");
else
System.out.println("Product of two numbers is not a buzz number");
}
}
Input:-
Enter first number:
3
Enter second number:
9
Output:-
Enter first number:
65
Enter second number:
72
Product of two numbers is : 27
Product of two numbers is a buzz number
Related topics:-
♨ What is Buzz number?
A number is said to be buzz number either it is divisible by seven or it ends with seven.
Examples of buzz number:-
- 77 is a buzz number.
As we can see it is divisible by seven (7 × 11) and the end the of the number is seven ( 7 ).
- 70 is a buzz number
Althoug it doesn't ends with 7 but it is divisible by seven therefore it is a buzz number.
- 27 is a buzz number
Althoug it's not divisible by seven but it ends with 7 therefore it is a buzz number.
♨ Syntax of if else statement :
if(condition)
{
----------------
Statements
----------------
}
else
{
----------------
Statements
----------------
}
:)