How to prevent the entry of a negtive number or a number with more than 4 digits
<p>I just want to find out if there is any way to block a user from entering either a negative number or a number with more than 4 digits. Also is there anyway to put this logic into a GUI? Here is my code:</p>

<pre><code>import java.util.Scanner;
public class EasterSunday
{
    public static void main(String[] args)
    {
        int year; // declarations
        Scanner input = new Scanner(System.in); //start Scanner
        System.out.println("Enter in a year to find out the day and month of that Easter Sunday.");
        year = input.nextInt();
        int a = year%19;
        int b = year%4;
        int c = year%7;
        int d = (19 * a + 24) %30;
        int e = (2 * b + 4 * c + 6 * d + 5) %7;
        int eSunday = (22 + d + e);
        if ((year &gt;= 1900) &amp;&amp; (year &lt;= 2099) &amp;&amp; (year != 1954) &amp;&amp; (year != 1981) &amp;&amp; (year != 2049) &amp;&amp; (year != 2076))
        {
            if (eSunday &lt;= 30)
                System.out.println("Easter Sunday in " + year + " is March, " + eSunday);
            else
                System.out.println("Easter Sunday in " + year + " is April, " + (eSunday - 30));
        }
        else
        {
            if (eSunday &lt;= 30)
                System.out.println("Easter Sunday in " + year + " is March, " + (eSunday - 7));
            else
                System.out.println("Easter Sunday in " + year + " is April, " + (eSunday - 37));
        }
    }
}
</code></pre>
