title: Vending Machine Program
body: <p>I have to create a simple vending machine program, where if the user inputs 2 tokens they get 1 can. I'm having a bit of trouble with the code - if I input 1 token and enter 'Y' I get the message "Thanks enjoy your drink" when it should really come up with an error.</p>
  
  <pre><code>import java.util.Scanner;
  /**
   * Vending Machine
   * 
   * @author - 
   * @version 1.0
   */
  
  public class VendingMachine
  {
  
  int cans = 10;
  int token = 20;
  
  public void fillUp (int cans)
  {
      if(cans &lt;= 0)
      {
          cans = cans+=10;            
      }
  
  }
  
  public void tokenIn (int token)
  {
      Scanner scan = new Scanner (System.in);
      System.out.println("Do you want something to drink? (Y/N)");
  
      boolean tokenIN = false;
      if(scan.next().equals("Y"))
      {
          tokenIN = true;
      }
      else
      {
          tokenIN = false;
      } 
  
      if(tokenIN = true &amp;&amp; token &gt;= 2 &amp;&amp; cans &gt;=1)
      {
          cans--;
          token-=2;
          System.out.println("Thanks, enjoy your drink!");    
      }
      else
      {
          System.out.println("Goodbye");
      }
  
  }
  
  public void getTokenCount (int token)
  {
      System.out.println(token);
  }
  
  public void getCansCount (int cans)
  {
      System.out.println(cans); 
  }
  }
  </code></pre>