Connecting Tech Pros Worldwide Forums | Help | Site Map

java simple user menu

Newbie
 
Join Date: Oct 2009
Posts: 31
#1: 3 Weeks Ago
Hi all,

im attempting to make a user menu, which the user instigates the exit, not netbeans.

basically i want a menu displayed,
user makes selection,
that specific piece is ran,
on completion the user is returned to the main menu.

The following is my attempt, however its not doing what i need. i get no errors

Expand|Select|Wrap|Line Numbers
  1. /*
  2.  * To change this template, choose Tools | Templates
  3.  * and open the template in the editor.
  4.  */
  5.  
  6. package week7;
  7. //import java.io.*;
  8. //import java.io.IOException;
  9. import java.util.Scanner;
  10. /**
  11.  *
  12.  * @author Administrator
  13.  */
  14. public class whileDoTest {
  15.  
  16.     @SuppressWarnings("empty-statement")
  17.     public static void main (String[]arguments)
  18.     {
  19.  
  20.         int menuSelect = 0;
  21.        if (menuSelect ==0){
  22.             System.out.println("Please make your selection");
  23.             System.out.println("");
  24.             System.out.println("(1) - New book     :     (2) - New user     :     (3) - New Load");
  25.             Scanner scan = new Scanner(System.in);
  26.             menuSelect = scan.nextInt();
  27.        }else{
  28.             switch (menuSelect)
  29.             {
  30.                 case 1:
  31.                    if(menuSelect == 1) {
  32.                     System.out.println("Selection 1");
  33.                     System.out.println("(1) - Main Menu");
  34.  
  35.                     break;
  36.                    }menuSelect = 0;
  37.                 case 2:
  38.                     if(menuSelect ==2) {
  39.                     System.out.println("Selection 2");
  40.                     break;
  41.                     }
  42.                 case 3:
  43.                     if (menuSelect ==3){
  44.                     System.out.println("Selection 3");
  45.                     break;
  46.                     }
  47.  
  48.  
  49.             }
  50.  
  51.             }
  52.     }
  53. }
  54.  
  55.  
  56.  

Newbie
 
Join Date: Oct 2009
Posts: 31
#2: 3 Weeks Ago

re: java simple user menu


also, i removed the break from the cases, and remove the else if
Reply