Java using else if to assign a value : <p>I'm very new to programming and Java. I'm trying to use else if to assign a value to a variable if they selected the correct input. But whenever I try to compile it, it says it cannot find the variable.</p>

<pre><code>import java.util.Scanner;

public class TDEE
{
    public static void main(String[] args)
    {

    Scanner in = new Scanner(System.in);

    double tdee = 0.0;

    System.out.print("Please enter your name: ");
    String name = in.next();

    System.out.print("Please enter your BMR: ");
    double bmr = in.nextDouble();

    System.out.print("Please enter your Gender (M/F): ");
    String gender = in.next();
    System.out.println();

    // providing menu items
    System.out.println("Select your activity level: ");
    System.out.println("[0] Resting (Sleeping. Reclining)");
    System.out.println("[1] Sedentary (Minimal Movement)");
    System.out.println("[2] Light (Sitting, Standing)");
    System.out.println("[3] Moderate (Light Manual Labor, Dancing, Riding Bike)");
    System.out.println("[4] Very Active (Team Sports, Hard Manual Labor)");
    System.out.println("[5] Extremely Active (Full-time Athlete, Heavy Manual Labor)");
    System.out.println();

    // accept user choice with a Scanner class method
    System.out.print("Enter the number corresponding to your activty level(0,1,2,3,4, or 5): ");
    String choice = in.next();
    System.out.println();

    if(choice.equalsIgnoreCase("0"))
    {
        double activityFactor = 1.0;
    }

    else if(choice.equalsIgnoreCase("1"))
    {
        double activityFactor = 1.3;
    }

    else if(choice.equalsIgnoreCase("2") &amp;&amp; "M".equals(gender))
    {
        double activityFactor = 1.6;
    }

    else if(choice.equalsIgnoreCase("2") &amp;&amp; "F".equals(gender))
    {
        double activityFactor = 1.5;
    }

    else if(choice.equalsIgnoreCase("3") &amp;&amp; "M".equals(gender))
    {
        double activityFactor = 1.7;
    }

    else if(choice.equalsIgnoreCase("3") &amp;&amp; "F".equals(gender))
    {
        double activityFactor = 1.6;
    }

    else if(choice.equalsIgnoreCase("4") &amp;&amp; "M".equals(gender))
    {
        double activityFactor = 2.1;
    }

    else if(choice.equalsIgnoreCase("4") &amp;&amp; "F".equals(gender))
    {
        double activityFactor = 1.9;
    }

    else if(choice.equalsIgnoreCase("5") &amp;&amp; "M".equals(gender))
    {
        double activityFactor = 2.4;
    }

    else if(choice.equalsIgnoreCase("5") &amp;&amp; "F".equals(gender))
    {
        double activityFactor = 2.2;
    }

    else
    {
        System.out.println("You did not choose a valid manu option.");
    }

    tdee = bmr * activityFactor;

    System.out.println();
    System.out.println("Name: " + name + "      Gender: " + gender);
    System.out.println("BMR: " + bmr + "       Activity Factor: " + activityFactor);
    System.out.println("TDEE: " + tdee);
    }
}
</code></pre>
