Need some help...don't know what I am doing wrong

here is the code...if I type anything other than a number it continually loops without asking for input again...what do I need to do differently.
* SongMenu.java
* Created on November 14, 2005, 8:55 PM
* To change this template, choose Tools | Options and locate the template under
* the Source Creation and Management node. Right-click the template and choose
* Open. You can then make changes to the template in the Source Editor.
import java.util.*;
* @author jessekangas-hanes
public class SongMenu {
    /** Creates a new instance of SongMenu */
    public SongMenu() {
     * @param args the command line arguments
    public static void main(String[] args) {
        // TODO code application logic here
        boolean menu = true;
        Scanner kbd = new Scanner(System.in);
        int menuselection;
        while(menu){
            try{
            System.out.println("--------------------------------------------------------------------------");
            System.out.println("|         Menu                                                           |");
            System.out.println("| 1 = create a new song list                                             |");
            System.out.println("| 2 = read songs into the current song list from a file                  |");
            System.out.println("| 3 = Input a song from the keyboard and addit to the current song list  |");
            System.out.println("| 4 = Select on or more songs from the current song list                 |");
            System.out.println("| 5 = Display current song list on the console                           |");
            System.out.println("| 6 = Print selected song(s) to the console                              |");
            System.out.println("| 7 = Write the current song list to a file                              |");
            System.out.println("| 8 = Write the selected songs to a file                                 |");
            System.out.println("| 9 = listen to selected songs (or all the current songs)                |");
            System.out.println("| 0 = Quit the Program                                                   |");
            System.out.println("--------------------------------------------------------------------------");
                menuselection = kbd.nextInt();
                switch (menuselection){
                     case 1:
                        break;
                    case 2:
                        break;
                    case 3:
                        break;
                    case 4:
                        break;
                    case 5:
                        break;
                    case 6:
                        break;
                    case 7:
                        break;
                    case 8:
                        break;
                    case 9:
                        break;
                    case 0:
                        menu = false;
                        break;
                    default:
                                break;
            catch (InputMismatchException e){
                System.out.println("Invalid selection.\nPlease Try Again");
}

Try this:
                menuselection = kbd.nextInt();
                kbd.nextLine(); // clears the rest of the line for inputs like: 1 a
            catch (InputMismatchException e){
                System.out.println("Invalid selection.\nPlease Try Again");
                kbd.nextLine(); // clears the line for bad inputs like: w
            ...

Similar Messages

Maybe you are looking for

  • Inserting timesten imdb cache is taking more time than insert in db11g

    Hi, I'm very new in Timesten imdb cache. I just recently installed imdb cache in an app server then installed oracle 11g in a db server and get to integrate them. So i wanted to test the performance of imdb cache .. i create an insert scripts that wi

  • Help reopen case for reset of phone

    The account limit was reached on my iPhone and it needs to be reset.

  • PSE8 & Dual Monitor Question

    I just connected an external display to my MacBook Pro & have a couple of very remedial questions. I have the displays set up in the "extended desktop" mode. But when I open an image in ACR, I cannot drag the ACR window to my external display. Can yo

  • VOIP home lab with cisco 2620 and VIC-2FXO port

    Hi all, I m considering building a home lab for studying CCVP, the lab would be based on the follow components : - CUCM 8.X (already installed) - A couple of soft phones running in VMWARE with IP Blue and CIPC (they are already in place and registere

  • Queries regarding Boleto and Duplicata

    Hi All, I am a new member of this site.We have got a requirement for developing sap scripts for Brazil.  Did anyone happen to work on Boleto and duplicata? The standard forms available are J_1b_boleto_itau and j_1b_duplicata. Can anyone please explai