How do I inititialize the variable?
<p>So I have a program which will print out the number of days into a year you are from a date given by the user, which includes leap years. However, when I complile the program it says the variable dayNumber is not initialized. How do I fix this?</p>

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

public class Days
{
public static void main( String [] args )
{
    Scanner scan = new Scanner(System.in);
    int month, day, year;
    int dayNumber;

    System.out.print("Enter the month: ");
    month = scan.nextInt();
    System.out.print("Enter the day: ");
    day = scan.nextInt();
    System.out.print("Enter the year: ");
    year = scan.nextInt();

    if ( month == 1 )

        dayNumber = day;

    else if ( month == 2 )

        dayNumber = 31 + day;   

    else if ( month == 3 )

        if ( year % 400 == 0 )

            if ( year % 4 == 0 &amp;&amp; year % 100 != 0 )

                dayNumber = 31 + 29 + day;


        else

            dayNumber = 31 + 28 + day;



    else if ( month == 4 )

        if ( year % 400 == 0 )

            if ( year % 4 == 0 &amp;&amp; year % 100 != 0 )

                dayNumber = 31 + 29 + 31 + day;


        else

            dayNumber = 31 + 28 + 31 + day;



    else if ( month == 5 )

        if ( year % 400 == 0 )

            if ( year % 4 == 0 &amp;&amp; year % 100 != 0 )

                dayNumber = 31 + 29 + 31 + 30 + day;


        else

            dayNumber = 31 + 28 + 31 + 30 + day;


    else if ( month == 6 )

        if ( year % 400 == 0 )

            if ( year % 4 == 0 &amp;&amp; year % 100 != 0 )

                dayNumber = 31 + 29 + 31 + 30 + 31 + day;


        else

            dayNumber = 31 + 28 + 31 + 30 + 31 + day;


    else if ( month == 7 )

        if ( year % 400 == 0 )

            if ( year % 4 == 0 &amp;&amp; year % 100 != 0 )

                dayNumber = 31 + 29 + 31 + 30 + 31 + 30 + day;


        else

            dayNumber = 31 + 28 + 31 + 30 + 31 + 30 + day;


    else if ( month == 8 )

        if ( year % 400 == 0 )

            if ( year % 4 == 0 &amp;&amp; year % 100 != 0 )

                dayNumber = 31 + 29 + 31 + 30 + 31 + 30 + 31 + day;


        else

            dayNumber = 31 + 28 + 31 + 30 + 31 + 30 + 31 + day;


    else if ( month == 9 )

        if ( year % 400 == 0 )

            if ( year % 4 == 0 &amp;&amp; year % 100 != 0 )

                dayNumber = 31 + 29 + 31 + 30 + 31 + 30 + 31 + + 31 + day;


        else

            dayNumber = 31 + 28 + 31 + 30 + 31 + 30 + 31 + 31 + day;


    else if ( month == 10 )

        if ( year % 400 == 0 )

            if ( year % 4 == 0 &amp;&amp; year % 100 != 0 )

                dayNumber = 31 + 29 + 31 + 30 + 31 + 30 + 31 + + 31 + 30 + day;


        else

            dayNumber = 31 + 28 + 31 + 30 + 31 + 30 + 31 + 31 + 30 + day;


    else if ( month == 11 )

        if ( year % 400 == 0 )

            if ( year % 4 == 0 &amp;&amp; year % 100 != 0 )

                dayNumber = 31 + 29 + 31 + 30 + 31 + 30 + 31 + + 31 + 30 + 31 + day;


        else

            dayNumber = 31 + 28 + 31 + 30 + 31 + 30 + 31 + 31 + 30 + 31 + day;


    else 

        if ( year % 400 == 0 )

            if ( year % 4 == 0 &amp;&amp; year % 100 != 0 )

                dayNumber = 31 + 29 + 31 + 30 + 31 + 30 + 31 + + 31 + 30 + 31 + 30 + day;


        else

            dayNumber = 31 + 28 + 31 + 30 + 31 + 30 + 31 + 31 + 30 + 31 + 30 + day;


    System.out.println("The date " + month + "/" + day + "/" + year + " is day number " + dayNumber);

}
}
</code></pre>

<p>Thank you for any help you can give!</p>
