title: Why is "body" being reset to zero?
body: <p>My program draws a cootie monster (a body and a head) and the body HAS to be drawn before the head. But when I run the program, it says "Can't add body part!" when I type in 2 as the input (even when I already have the body drawn). NOTE: 1 as an input draws the body and 2 draws the head.</p>
  
  <p>I've identified the problem already, but I'm not sure how to fix it. The problem is that head is being reset to 0 before it enters the "if (rollValue == 2)...". My program can draw the body, but after it finished drawing the body, my "body" variable seems to get set back to 0. Which is why my program isn't drawing the head. Any ideas on how to fix it so that my program doesn't reset "body" back to 0 after drawing the body?</p>
  
  <pre><code>import java.util.Scanner;
  
  public class Cootie
  {
     public static void main(String[] args)
     {
        boolean done = false;
  
        while (!done)
        {
           Scanner scanner = new Scanner(System.in);
           System.out.println("BODY PARTS:");
           System.out.println("1 = body");
           System.out.println("2 = head");
           System.out.println("3 = one leg");
           System.out.println("4 = one antenna");
           System.out.println("5 = one eye");
           System.out.println("6 = tail");
           System.out.println("What number did you roll?: ");
           int rollValue = scanner.nextInt();
  
           int body = 0;
           int head = 0;
  
           if (rollValue == 1)
           {
              if (body == 0)
              {
                 body = 1;
              }
              else
              {
                 System.out.println("Can't add body part!");
                 System.out.println(" ");;
              }
           }
           else if (rollValue == 2)
           {
              if (body == 1 &amp;&amp; head == 0)
              {
                 head = 1;
              }
              else
              {
                 System.out.println("Can't add body part!");
              }
           }
           else
           {
              System.out.println("Enter a valid input!");
           }
           if (body == 1)
           {
              System.out.println("------------------------------");
              System.out.println("You got the body!");
              System.out.println(" ");
              System.out.println(" ");
              System.out.println("   [ ]");
              System.out.println(" ");
              System.out.println("   [ ]");
              System.out.println(" ");
              System.out.println("   [ ]");
              System.out.println(" ");
           }
           if (head == 1)
           {
              System.out.println("You got the head!");
              System.out.println(" ");
              System.out.println("  (    )");
           }
           if (body == 1 &amp;&amp; head == 1)
           {
              System.out.println("Congratulations you have completed your cootie!");
              done = true;
           }
        }
     }
  }
  </code></pre>