### Calendar (Due 01 Mar 2013)

In this program you will prompt the user to enter the month and year. Your program will print out the calendar for that month and year.

Your program will check the following:

• The month is in the range 1 and 12.

• The year is between 1900 and 2100.
All the above limits are inclusive. If any one of the conditions fails then the program will keep prompting the user until the input is in the correct range.

Once you have the correct month and year you will use Rev. Zeller's algorithm to find out what day of the week the first of the month was for that year.

In Rev. Zeller's algorithm the following terms a, b, c, and d are defined as follows:

• a ≡ the month of the year, with March = 1, April = 2, … with January = 11, and February = 12 of the preceding year

• b ≡ the day of the month

• c ≡ the year of the century

• d ≡ the century

For example, 31 July 1929, gives a = 5, b = 31, c = 29, and d = 19. Similarly, 3 January 1988, gives a = 11, b = 3, c = 87, and d = 19.

Now compute the following quantities:

• w = (13 * a - 1 ) / 5

• x = c / 4

• y = d / 4

• z = w + x + y + b + c - 2 * d

• r = z % 7
• r = (r + 7) % 7 [to care of negative values of r]

r gives the day of the week, where r = 0 represents Sunday, r = 1 represents Monday, and so on.

Here is a possible Input / Output scenario:

```
Enter Month (1 - 12): 15

Enter Month (1 - 12): 2

Enter Year (1900 - 2100): 1850

Enter Year (1900 - 2100): 2012

Feb             2012
Su Mo Tu We Th Fr Sa
1  2  3  4
5  6  7  8  9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29

```

Assume that the user only enters integers that can be stored in an int. Here is the order of operation:

• Prompt the user for month and check.
• Prompt the user for year and check.
• Find day of the week for the first of the month for that year.
• Find number of days for that month.
• If the month is February, check if the year is a leap year, and adjust the number of days accordingly.
• Print out the formatted calendar for that month.

Here are the constraints on the output:

• There should be a blank line before and after the calendar.
• All the month names must be 3 letters - Jan, Feb, Mar, Apr, May, Jun, Jul, Aug, Sep, Oct, Nov, and Dec.
• The month will be printed on the left and the year on the right.
• The days of the week must be abbreviated as follows - Su, Mo, Tu, We, Th, Fr, Sa. There should be just one space between the days.
• The days should be printed out right justified. Use System.out.printf() for formatted printing.

The class that you will be writing will be called Calendar. We will be looking at good documentation, design, and adherence to the coding convention mentioned below. You may use the same variable names used in the problem statement or come up with your own. You must use Scanner for your input. Your file Calendar.java will have the following header:

```/*
File: Calendar.java

Description:

Student Name:

Student UT EID:

Course Name: CS 312

Unique Number:

Date Created:

*/
```

You will follow the standard Java Coding Conventions. You can either view the HTML page or download the PDF or Postscript and print it out. There is a modification that I would like to make to the standard coding conventions. Please align the opening and closing braces vertically so that you can easily make out the blocks of code. For example:

```Do this:
if ( x > 5 )
{
a = b + c;
}

Not this:
if ( x > 5 ) {
a = b + c;
}

```

Use the turnin program to submit your .java file. We should receive your work by 11 PM on Friday 01 Mar 2013. There will be substantial penalties if you do not adhere to the guidelines.

• You must submit the .java file and not the .class file.
• Your .java file should have the header with the proper documentation.
• You should be submitting your .java file through the web based turnin program. We will not accept files e-mailed to us.
• Compile and run your code on the command line.
• Your code must compile before submission.
• Here is the Grading Criteria.