java simple user menu

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • whitep8
    New Member
    • Oct 2009
    • 65

    #1

    java simple user menu

    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

    Code:
    /*
     * 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;
                        }
                       
    
                }
                
                }
        }
    }
  • whitep8
    New Member
    • Oct 2009
    • 65

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

    Comment

    Working...