Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Answers Viewqa Java-Beginners console application - text-based menu

Have Programming Question? Ask it here!
 
 
 


brenz
console application - text-based menu
1 Answer(s)      4 years and 8 months ago
Posted in : Java Beginners



Advertisement
View Answers

December 5, 2009 at 2:40 PM


Hi Friend,

Use Switch-Case in your program like the following:

import java.util.*;

class addproduct{
addproduct(){
System.out.println("I am the class addproduct");
}
}

class updateproduct{
updateproduct(){
System.out.println("I am the class updateproduct");
}
}

class deleteproduct{
deleteproduct(){
System.out.println("I am the class deleteproduct");
}
}

class viewproduct{
viewproduct(){
System.out.println("I am the class viewproduct");
}
}



public class productmain{
public static void main(String[] args) throws Exception {
Scanner scan = new Scanner(System.in);
int menu = 0;
System.out.println("Test");
System.out.println();
System.out.println("1. Add Product");
System.out.println("2. Update Product");
System.out.println("3. Delete Product");
System.out.println("4. View Product");
System.out.println("5. Exit");

boolean quit = false;
do{
System.out.print("Please enter your choice: ");
menu = scan.nextInt();
System.out.println();
switch(menu) {
case 1:
addproduct add=new addproduct();
break;
case 2:
updateproduct update=new updateproduct();
break;
case 3:
deleteproduct delete=new deleteproduct();
break;
case 4:
viewproduct view=new viewproduct();
break;
case 5:
quit = true;
break;
default:
System.out.println("Invalid Entry!");
}
}
while (!quit);
}
}

Thanks


Related Tutorials/Questions & Answers:
CONSOLE
class. Standard output is, on most operating systems, console output. format
menu
menu  fibonaci & prime no. display in menu driven in java programme
Advertisements
menu
menu  Hi,i want write the menu that repeat several time
Menu
Menu  Pl make a program which generates the following output. "Select from this menu" 1. Array 2. Stack 3. Queue. 4. Exit. If users press 1, then it will go in 1. Array. Welcome in Array. press 1. for Insertion press 2
How to Create Animated Main Menu Application with Java Swnig Buttons - Java Beginners
How to Create Animated Main Menu Application with Java Swnig Buttons  Hello sir I want to display Main Menu after Log in i have created Log in Form but I want More attractive Animated Main Menu which includes Following
Faces Console
Faces Console         The Faces Console is a FREE standalone Java Swing application for managing JavaServer Faces-based applications. With the Faces Console you
Spring Console
Spring Console         The Spring Console is a FREE standalone Java Swing application for developing and managing Spring-based applications. With the Spring Console
Struts Console
Struts Console         The Struts Console is a FREE standalone Java Swing application for managing Struts-based applications. With the Struts Console you can
How to invoke other java class by selecting from dropdown menu and subsequently clicking button in java swing application
How to invoke other java class by selecting from dropdown menu... a dropdown menu to choose type of report and then click on submit button.On clicking... which he can generate report based on diffrent textfield values entered And vice
How to invoke other java class by selecting from dropdown menu and subsequently clicking button in java swing application
How to invoke other java class by selecting from dropdown menu... a dropdown menu to choose type of report and then click on submit button.On clicking... which he can generate report based on diffrent textfield values entered And vice
How to invoke other java class by selecting from dropdown menu and subsequently clicking button in java swing application
How to invoke other java class by selecting from dropdown menu... a dropdown menu to choose type of report and then click on submit button.On clicking... which he can generate report based on diffrent textfield values entered And vice
Invalid console appender in JBoss console
Invalid console appender in JBoss console  "ERROR: invalid console appender config detected, console stream is looping" The above is the error i am getting while starting the server after deploying the ear file into the jboss. I
menu problem
menu problem  Hi to all , I am inserting a menu in my jsp page.i have downloaded(free) a menu .In which 4 files are as below. 1... it to the tomcat and when i run my application , an extra link appears on my header
menu driven
menu driven  display the 1-30 prime no. and fibonacie series in menu driven programme
menu driven
menu driven   menu driven programm in decimal to binary binary to decimal
menu with scrollbar
menu with scrollbar  I want to use MenuBar with Scrollbar. I tried... and every component should inside the panel. I tried it but menu bar... java.awt.*; public class menu extends JFrame { MenuBar bar; Menu file,setting,rate,help
DropDown Menu
menu that has the list of Page 1- Page 5. if i select page 1 it will display only... is the problem.. for example; if i select page 1 in my dropdown menu, and click
Menu Bar in Java
to create a Menu Bar in your application, First we need to import list of packages that required for creating a menu bar in an application. We defined a class name... Menu Bar in Java     
Add menu - IDE Questions
to develop web application but i cant find how to add menu item(not the case for java application where menu can be added from palette)so that when i run the application using browser i can see the menus and select accordingly,Plz help me.Thanks
ClearScreen in Console Java
ClearScreen in Console Java  How can I perform Clear Screen Operation in Java. As we used to do in C++ using clrscr(); Please guide
soap message console - WebSevices
soap message console  hi friends i have one doubt that is iam using MyEclipse 6.0 in that how do i get soap message console
Need help with console program?
Need help with console program?  Write a console program that repeatedly prompts the user to enter data until they type done (any case, Upper, Lower, or Mixed). thanks in advance.   Here is an example that repeatedly
HIBERNATE IN CONSOLE & SERVLET
for using Hibernate in a console application & a servlet. ... advisable to test the program as a console application. Once it is found to work... HIBERNATE IN CONSOLE & SERVLET ( part-3
Creating Menu - MobileApplications
Creating Menu  Hi all, I am developing an application for nokia... and JDK 1.5 with Wireless toolkit and was able to create a simple application to display a text on the screen. I need to know the following things: How
menu driven programme
menu driven programme   calculate the area of circle, square, rectangle in menu driven programme in java
menu drive programm in java
menu drive programm in java  calculate area of circle, square,rectangele in menu driven programme in java
menu drive programm in java
menu drive programm in java  calculate area of circle, square,rectangele in menu driven programme in java
creaing a menu - Java Beginners
creating a menu in JavaScript  How we can create a 3-level menu in java script
drop down menu
drop down menu  drop down menu using html
Menu s - JSP-Servlet
Menu s  How to create menubar & menus & submenus in jsp
Menu Bar prob.
Menu Bar prob.  I want a menu to be displayed in each page of my swing appl. how to go abt
java console programming - Java Beginners
java console programming  how to clear d screen in java console programming
highlight menu item html
highlight menu item html  highlight menu item in html or CSS   <body id="index"> <div id="menu"> <ul> <li class...; </ul> </div> <!-- menu --> </body>
Jquery Slide-up Menu
Jquery Slide-up Menu  Hello, Excellent site. I am learning Jquery and I can produce a slide-down menu but don't know how to make a slide-up menu/nav bar to go at the bottom of the web page. Can you show a way how this can
context menu overlapped in IE8
context menu overlapped in IE8  I developed a contex menu in XHTML while opening it is overlapped in border of IE8 browser. even i have tried change the zaxis in css. I am using like below
creating pop up menu
creating pop up menu   how to create a pop up menu when a link in html page is clicked using jquery? and the link should be a text file   Please visit the following links: http://www.roseindia.net/tutorial/jquery
HTML - menu tag example
HTML - menu tag example Description : The <menu> is a tag of HTML. Which is used to create a menu list in our web page. Code : <!DOCTYPE...>HTML -- menu tag.</h1> <p>Creates a menu list
tree menu delete node
tree menu delete node  I have crated a tree menu having various sub nodes now i want to delete parent node and also want to delete sub nodes when parent node is deleted........i am using servlet and giving nodeid to servlet
Dojo Menu and Menu Item
Dojo Menu and Menu Item          In this section, you will learn about the menu and how to create it in dojo. Try Online: Menu and Menu Item Menu : This is the widget models
Console Output
Java NotesConsole Output You can write programs that write text lines to the "console", which is typically a DOS command window.../ConsoleOutput.java // Purpose: This program shows a message on the console. // Author
JSP output in Console - JSP-Servlet
JSP output in Console  Q:An input text should be read and the same should be printed in the CONSOLE. Actually i was able to do it in the browser, but unable to get in the CONSOLE. Can anyone tell me how could i do
Hibernate generated SQL statements on console
Hibernate generated SQL statements on console  If you want to see the Hibernate generated SQL statements on console, what should we do?   If you want to see the Hibernate generated SQL statements on console just add
Menu Shortcuts
Menu Shortcuts       The MenuItem class also provides a feature of menu shortcuts and speed keys. You must be familiar with the menu shortcuts such as Ctrl-P which is used to give
i am getting an error in adding a menu item to a menu.
i am getting an error in adding a menu item to a menu.   i am not able to execute the menu program. i am getting an error at menu.add(menuitem); it says add method is undefined for type menu. but as far as i know that is only way
Input From Console
-based console device associated with the current Java virtual machine... to Reads a single line of text from the console and further these two... Input From Console     
Create Menu Bar in SWT
Create Menu Bar in SWT       This section illustrates you how to create a menu bar. In SWT, the classes Menu and MenuItem of package org.eclipse.swt.widgets is allowed
Redirecting the console output into a file in Java
Redirecting the console output into a file in Java  Hi, i coded a program that read specific lines from a text file. It's working well. Now i want to redirect the output of the console to a text file. i used your tutorial
Need help writing a console program
Need help writing a console program  I need help cant seems to figure it out! Write a program that consists of three classes. The first class will be the actual program. The second class will simply convert a string to lower
How to Creating Pop Up Menu in PHP?
How to Creating Pop Up Menu in PHP?  Hi, I am a beginner in the PHP Application. Can somebody give an example of how to creating pop up Menu in PHP. Please feel free to suggestion........ Thanks
menu bar in javascript - JSP-Servlet
menu bar in javascript  sir i need to display menu bar with some background color.in each menu,there are some values to display as menu.again if i select each value,again a sub menu to display.plz send me some code. menubar
 

 

 

DMCA.com