Computer Science, asked by ranisahbgpp9c9de, 1 year ago

Wap in Java to insert five no and check it is a buzz no

Answers

Answered by QGP
3
Hey There,

Here is the Code for the Program which will accept a number from the user, and check whether it is a Buzz Number or not.

To check if "5" is a Buzz Number, input 5 in the Program.

import java.util.Scanner;
public class BuzzNumber
{
    public static void main(String[] args)
    {
        Scanner sc = new Scanner(System.in);
       
        System.out.println("A Buzz Number is a number which ends in 7 or which is divisible by 7.\n");
       
        System.out.print("Enter the number: ");
        int n = sc.nextInt();
       
        if((n%7 == 0)||(n%10 == 7))
        {
            System.out.println(n+" is a Buzz Number");
        }
        else
        {
            System.out.println(n+" is not a Buzz Number");
        }
    }
}



Hope it helps
Purva
Brainly Community

Answered by anindyaadhikari13
2

\star\:\:\:\sf\large\underline\blue{Question:-}

  • Write a program in Java to check whether a number is buzz number or not.

\star\:\:\:\sf\large\underline\blue{Code:-}

A number is said to be a buzz number if it is either divisible by 7 or the last digit is 7.

For example, 7 is a buzz number,14 ,21,37 and so on.

Here is the code,

import java.util.*;

class BuzzNumber

{

public static void main(String s[])

{

Scanner sc = new Scanner(System.in);

System.out.print("Enter a number: ");

int n=sc.nextInt();

if(n%7==0||n%10==7)

System.out.println("Number is a Buzz Number.");

else

System.out.println("Number is not a Buzz Number.");

}

}

Similar questions