title: Java Slot Machine
body: <p>I'm having issues with a homework problem for my CS class. I'm supposed to make a slot machine  and I can't get the continue to work, I get that the scanner nextLine method skips over the line and keeps what was there but it won't let me enter anything and it just ends the program. I also have to split this method up and make it 30 lines or less because of the formatting that is required by my professor. I also have to keep a running total for the winnings but I can't figure out how to do it for the jackpot.</p>
  
  <pre><code>/**
   * ProgrammingAssignment2.java
   * 
   * @author Corey Goff 
   * @version March 2013
   */
  import java.util.Random;
  import java.util.Scanner;
  /**
  * This class simulates a slot machine.
  */
  public class SlotMachine
  {
     /**
      * This is the main method.
      * 
      * @param args
      */
     public static void main(String[] args)
     {
         Scanner keyboard = new Scanner(System.in);
         Random random = new Random();
         String cont = "n";
         char answer;
         int coin = 0;
         int totalEntered = 0;
         int a;
         int b;
         int c;
         int n;
         int amountWon = 0;
         int dubs = coin * 2;
         int trips = coin * 4;
  
         while (cont.equals("n"))
         {
             a = random.nextInt(6);
             b = random.nextInt(6);
             c = random.nextInt(6);
             n = random.nextInt(991) +10;
             totalEntered += coin;
             System.out.println("How much would you like to bet? ");
             coin = keyboard.nextInt();
  
             switch (a) 
             {
                 case 0:
                     System.out.println("Cherry");
                     break;
                 case 1:
                     System.out.println("Orange");
                     break;
                 case 2:
                     System.out.println("Plum");
                     break;
                 case 3:
                     System.out.println("Bell");
                     break;
                 case 4:
                     System.out.println("Melon");
                     break;
                 default:
                     System.out.println("Bar");
             }
  
             switch (b) 
             {
                 case 0:
                     System.out.println("Cherry");
                     break;
                 case 1:
                     System.out.println("Orange");
                     break;
                 case 2:
                     System.out.println("Plum");
                     break;
                 case 3:
                     System.out.println("Bell");
                     break;
                 case 4:
                     System.out.println("Melon");
                     break;
                 default:
                     System.out.println("Bar");
             }
  
             switch (c) 
             {
                 case 0:
                     System.out.println("Cherry");
                     break;
                 case 1:
                     System.out.println("Orange");
                     break;
                 case 2:
                     System.out.println("Plum");
                     break;
                 case 3:
                     System.out.println("Bell");
                     break;
                 case 4:
                     System.out.println("Melon");
                     break;
                 default:
                     System.out.println("Bar");
             }
  
             if (a != b &amp;&amp; a != c &amp;&amp; b != c)
             {
                 System.out.println("You have won $0");
             }
             else if (a == b || a == c || b == c)
             {
                 System.out.println("Congratulations, you have won $" + dubs);
                    amountWon += dubs;
             }
             else if (a == b &amp;&amp; a == c &amp;&amp; a != 0)
             {
                 System.out.println("Congratulations, you have won $" + trips);
                    amountWon += trips;
             }
             else if (a == 0 &amp;&amp; b == 0 &amp;&amp; c == 0)
             {
                 System.out.println("Congratulations! You have won the jackpot of $" 
                     + (coin * n));
  
             }
  
             System.out.println("Continue? y/n ");
             cont = keyboard.nextLine();
         }
     }
  }
  </code></pre>