0% found this document useful (0 votes)
3 views1 page

Menu Driven Program Program 1

The document provides a Java program that allows users to perform three operations on a number based on their choice: check if it's a Buzz number, determine if it's even or odd, and assess if it's positive or negative. A Buzz number is defined as a number that is either divisible by 7 or ends with the digit 7. The program uses a menu-driven approach and includes a variable description table for clarity on variable usage.

Uploaded by

1981swapna.panda
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views1 page

Menu Driven Program Program 1

The document provides a Java program that allows users to perform three operations on a number based on their choice: check if it's a Buzz number, determine if it's even or odd, and assess if it's positive or negative. A Buzz number is defined as a number that is either divisible by 7 or ends with the digit 7. The program uses a menu-driven approach and includes a variable description table for clarity on variable usage.

Uploaded by

1981swapna.panda
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Program 1.

Write a menu driven program in Java to accept a number and perform the
following operations depending on the user's choice:
Entered number is a Buzz number or not.
Entered number is even or odd.
Entered number is positive or negative.
Note: A Buzz number is a number which is either divisible by 7 or has 7 in its unit's place.
Answer
import [Link];
public class KboatMenu
{
public static void main(String args[]) {
Scanner in = new Scanner([Link]);
[Link]("Type 1 for Buzz Number");
[Link]("Type 2 for Even/Odd");
[Link]("Type 3 for Positive/Negative");
[Link]("Enter your choice: ");
int ch = [Link]();
[Link]("Enter number: ");
int n = [Link]();
switch (ch) {
case 1:
if (n % 7 == 0 || n % 10 == 7)
[Link](n + " is a Buzz Number");
else
[Link](n + " is not a Buzz Number");
break;
case 2:
if (n % 2 == 0)
[Link](n + " is a Even Number");
else
[Link](n + " is an Odd Number");
break;
case 3:
if (n >= 0)
[Link](n + " is a Positive Number");
else
[Link](n + " is a Negative Number");
break;
default:
[Link]("Incorrect choice");
}
}
}
Variable Description Table
Variable Type Description
In Scanner Used to take user input from the keyboard
Ch Int Stores the choice you select (1, 2, or 3)
n int Stores the number entered by the user to check

You might also like