| | |
simple non gui menu
Please support our Java advertiser: Programming Forums - DaniWeb Sister Site
Thread Solved |
•
•
Join Date: Jun 2009
Posts: 142
Reputation:
Solved Threads: 2
Hi All,
Im attempting to make a simple java menu system. the psueo code is as follows
1. user is presented with menu
2. selection is made
3. that action is ran, i.e make a new user (i have this code seperate, which works)
4. the user is returned to the main menu.
what is actually happening is it keeps ending. I tried using a do while, but i cant seem to get my head around it.
Im attempting to make a simple java menu system. the psueo code is as follows
1. user is presented with menu
2. selection is made
3. that action is ran, i.e make a new user (i have this code seperate, which works)
4. the user is returned to the main menu.
what is actually happening is it keeps ending. I tried using a do while, but i cant seem to get my head around it.
Java Syntax (Toggle Plain Text)
/* * To change this template, choose Tools | Templates * and open the template in the editor. */ package week7; //import java.io.*; //import java.io.IOException; import java.util.Scanner; /** * * @author Administrator */ public class whileDoTest { @SuppressWarnings("empty-statement") public static void main (String[]arguments) { int menuSelect = 0; if (menuSelect ==0){ System.out.println("Please make your selection"); System.out.println(""); System.out.println("(1) - New book : (2) - New user : (3) - New Load"); Scanner scan = new Scanner(System.in); menuSelect = scan.nextInt(); }else{ switch (menuSelect) { case 1: if(menuSelect == 1) { System.out.println("Selection 1"); System.out.println("(1) - Main Menu"); break; }menuSelect = 0; case 2: if(menuSelect ==2) { System.out.println("Selection 2"); break; } case 3: if (menuSelect ==3){ System.out.println("Selection 3"); break; } } } } }
•
•
Join Date: Jun 2009
Posts: 142
Reputation:
Solved Threads: 2
0
#2 Nov 2nd, 2009
i have amended the code as follows, but i get an error when i want to return the value back to 0.
Java Syntax (Toggle Plain Text)
/* * To change this template, choose Tools | Templates * and open the template in the editor. */ package week7; //import java.io.*; //import java.io.IOException; import java.util.Scanner; /** * * @author Administrator */ public class whileDoTest { @SuppressWarnings("empty-statement") public static void main (String[]arguments) { System.out.println("Please make your selection"); System.out.println(""); System.out.println("(1) - New book : (2) - New user : (3) - New Load"); Scanner scan = new Scanner(System.in); int menuSelect = scan.nextInt(); // switch (menuSelect) do{ System.out.println("Selection 1"); System.out.println("(1) - Main Menu"); menuSelect ==0; }while (menuSelect==1); do{ if(menuSelect ==2) { System.out.println("Selection 2"); }while (menuSelect==2); do{ System.out.println("Selection 3"); } while (menuSelect ==3);
•
•
Join Date: Nov 2008
Posts: 332
Reputation:
Solved Threads: 54
0
#3 Nov 2nd, 2009
whiteyoh, look at static int ConsoleOptionGUI(String s) method http://www.daniweb.com/forums/thread231390.html
Yet you will not always write all the code in the main method.
Yet you will not always write all the code in the main method.
![]() |
Similar Threads
- Simple GUI - How much effort? (C++)
- Please suggest a very simple web design app (Site Layout and Usability)
- Simple GUI (Python)
- GUI JFrame squish (Java)
- Simple drop down menu (HTML and CSS)
- Simple CLI/GUI application for XHTML templates. (HTML and CSS)
- Simple DropDown Menu? (ASP.NET)
- A simple C++ GUI code request (ASP.NET)
- Time Refreshing on a GUI Menu Bar (Java)
Other Threads in the Java Forum
- Previous Thread: hey i need some help looking over my coding
- Next Thread: Hibernate Issue
Views: 283 | Replies: 3
| Thread Tools | Search this Thread |
Tag cloud for Java
android api apple applet application arguments array arrays automation binary bluetooth c# capture chat chatprogramusingobjects class classes client code color component count database detection draw eclipse eclipsedevelopment encryption error event exception file fractal game givemetehcodez graphics gridlayout gui helpwithhomework high html ide if_statement image input integer j2me java javadesktopapplications javaprojects jmf jni jpanel julia keyword linux list loop macintosh map method methods mobile multithreading netbeans newbie number object oracle os print problem producer program programming project projectideas read recursion replaysolutions scanner screen server set size sms socket sort sql string swing test threads time transfer transforms tree ui unicode windows





