
Java Netbeans


PROGRAM CODE:
// include the required libraries
import java.util.*;
class StaticMethods
{
// start definition of menuInteger function
public static int menuInteger()
{
// create object of scanne class
Scanner scan = new Scanner(System.in);
int ch;
// display the Menu
System.out.println("Menu: ");
System.out.println("1. 1000");
System.out.println("2. 2000");
System.out.println("3. 3000");
// use loop to iteration
while(true)
{
System.out.println("Enter the integer from menu: ");
// take the integer value from the user
ch = scan.nextInt();
// condition for valid input
if(ch==1000 || ch==2000 || ch==3000)
{
return ch;
}
// condition for invalid input
else
{
System.out.println("Invalid choice");
continue;
}
}
}
}
public class Main
{
// start definition of main function
public static void main(String[] args)
{
// declare the required variables
int result;
// create object of the required class
StaticMethods obj = new StaticMethods();
// call the function and store the result returned by the function
result = obj.menuInteger();
System.out.println("The user entered: "+result);
}
}
Step by stepSolved in 2 steps with 1 images

- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education





