| | |
simple non gui menu
Thread Solved |
•
•
Join Date: Jun 2009
Posts: 140
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: 140
Reputation:
Solved Threads: 2
0
#2 26 Days Ago
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: 53
0
#3 26 Days Ago
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
| Thread Tools | Search this Thread |
-xlint actionlistener android api applet application array arrays automation bi binary blackberry block bluetooth character chat class client code compile compiler component consumer database desktop developmenthelp eclipse error fractal freeze ftp game gameprogramming givemetehcodez graphics gui html ide image integer j2me j2seprojects java javac javaee javaprojects jetbrains jni jpanel jtable julia learningresources lego linked linux list loops mac map method methods mobile netbeans newbie notdisplaying number online printf problem program programming project properties qt recursion researchinmotion rotatetext rsa scanner screen server set singleton sms sort sql string swing system textfields threads time title tree tutorial-sample update variablebinding windows working xor





