title: Java Homework - Scanner object using next() and nextLine() methods
body: <p>I am writing a main method to provide a menu for a Contact class and ContactBook class that I wrote for a java class that I am taking.  My issue is that I expected that when the user enters either A, F, P, or Q that my Scanner object (kbd) would capture the input, use it, and move on once the next input is entered.  There is obviously something key that I am not understanding as pushing return doesn't always advance my program as I had expected.  I have included my code and the output.  Any tips would be greatly appreciated.</p>
  
  <pre><code>  import java.util.Scanner;
    public class run{
    public static void main(String[]args){
        Scanner kbd = new Scanner(System.in);
        boolean quit = false;
        System.out.println("How many contacts would you like in your Contact Book?: ");
        int size = kbd.nextInt();
        kbd.nextLine();
        ContactBook kevin = new ContactBook(size);
        while(!quit){
           System.out.println("A - Add a contact \n"+
                              "F - Find a contact \n"+
                              "P - Prints the list \n"+
                              "Q - Quits");
  
  
           if(kbd.next().equals("A")){
              if(ContactBook.full(kevin))
                 System.out.println("Contact book full!");
              else{
                 Contact temp = new Contact();
                 System.out.println("Enter a First Name: ");
                 temp.setFirstName(kbd.nextLine());
                 System.out.println("Enter a Last Name: ");
                 temp.setLastName(kbd.nextLine());
                 System.out.println("Enter a Phone Number: ");
                 temp.setPhoneNumber(kbd.nextLine());
                 System.out.println("Enter an email: ");
                 temp.setEmail(kbd.nextLine());
                 kevin.addContact(temp);
              }
           }
           if(kbd.next().equals("F")){
              kevin.search();
           }
           if(kbd.next().equals("P")){
              System.out.print(kevin.produce());
           }
           if(kbd.next().equals("Q")){
              quit = true;
           }
        }
     }
  }
  </code></pre>
  
  <p>Here is the output that I am getting.</p>
  
  <pre><code> ----jGRASP exec: java run
  How many contacts would you like in your Contact Book?: 
  3
  A - Add a contact 
  F - Find a contact 
  P - Prints the list 
  Q - Quits
  A
  Enter a First Name: 
  Kevin
  Enter a Last Name: 
  Smith
  Enter a Phone Number: 
  312-4567
  Enter an email: 
  kevin@gmail.com
  
  
  
   //here I keep pushing enter and am not sure why it doesn't continue back to
   //the beginning of my while loop
  
  
  
  a
  a
  a
  A - Add a contact 
  F - Find a contact 
  P - Prints the list 
  Q - Quits
  
  a
  
   ----jGRASP: process ended by user.
  
   ----jGRASP exec: java run
  How many contacts would you like in your Contact Book?: 
  
   ----jGRASP: process ended by user.
  
   ----jGRASP exec: java run
  How many contacts would you like in your Contact Book?: 
  4
  A - Add a contact 
  F - Find a contact 
  P - Prints the list 
  Q - Quits
  A
  Enter a First Name: 
  Enter a Last Name: 
  Smith
  Enter a Phone Number: 
  312-4567
  Enter an email: 
  kevin@gmail.com
  
  a
  s
  d
  A - Add a contact 
  F - Find a contact 
  P - Prints the list 
  Q - Quits
  </code></pre>
  
  <p>Again, I am a student and this is for my second Java class.  I have checked many resources in an attempt to understand what I am doing wrong and I haven't been able to piece it together.  Hopefully someone can shed some light on this for me.  Thanks.</p>