Description
Objectives:
Practice two-dimensional arrays
Assignment:
In this assignment, you are going to create a single month of a calendar based on user input. You need to ask the
user for the year, month, and day of the week of the first day of the month they entered. From this information,
you will generate the calendar for that month. You will need to make sure that the month has the correct number
of days, thus you will also need to check if the year entered is a leap year. You will need to make sure that the
first day of the month is on the correct day of the week.
Programming Notes:
You MUST store the dates for the calendar in a two-dimensional array. It should have 6 rows and 7
columns.
You MUST display the values stored in the two-dimensional array when displaying the days of the
calendar.
You MUST do input validation for all of the user input.
o Numbers must be integers (no floating-point numbers or words)
You MUST use exception handling for this.
o Numbers must be in the correct range.
2
Sample Execution 1: No Errors
Create a Calendar
=================
Enter Year: 2017
Enter Month
———–
1. January 5. May 9. September
2. February 6. June 10. October
3. March 7. July 11. November
4. April 8. August 12. December
Enter Month (1 – 12): 7
Choose Day of Week of the 1st Day
———————————
1. Sunday 5. Thursday
2. Monday 6. Friday
3. Tuesday 7. Saturday
4. Wednesday
Enter Day of the Week (1 – 7): 7
July 2017
——————–
S M T W T F S
——————–
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
30 31
3
Sample Execution 2: Errors
Create a Calendar
=================
Enter Year: sdlfkj
Enter Year: -0234
Enter Year: 9234.0
Enter Year: 2016
Enter Month
———–
1. January 5. May 9. September
2. February 6. June 10. October
3. March 7. July 11. November
4. April 8. August 12. December
Enter Month (1 – 12): sdfer
Enter Month (1 – 12): 0
Enter Month (1 – 12): 13
Enter Month (1 – 12): -234
Enter Month (1 – 12): 3.543
Enter Month (1 – 12): 12
Choose Day of Week of the 1st Day
———————————
1. Sunday 5. Thursday
2. Monday 6. Friday
3. Tuesday 7. Saturday
4. Wednesday
Enter Day of the Week (1 – 7): 0
Enter Day of the Week (1 – 7): 8
Enter Day of the Week (1 – 7): 1234
Enter Day of the Week (1 – 7): e;lfj
Enter Day of the Week (1 – 7): 0.24
Enter Day of the Week (1 – 7): -24
Enter Day of the Week (1 – 7): 5
December 2016
——————–
S M T W T F S
——————–
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 30 31
4
Requirements:
Use an updated comment block
Your program should use the following comment block at the very beginning of your program.
// Name: Your Name Date Assigned: Fill in
//
// Course: CSCI 2003 60357 Date Due: Fill in
//
// Instructor: Ms. Greer
//
// File name: Fill in
//
// Program Description: Brief description of what the program does.
Use appropriate comments throughout the program
Make good use of whitespace
Your output should look exactly like the sample output if using the same data.
Deliverables:
Calendar.java file
Upload 1 file to Moodle
Grading:
Total Points 15 points
Calendar class 15 points
Gets year correctly 0.5 points
Displays month options 0.5 points
Gets month correctly 1 points
Checks if year is leap year 1 points
Determines number of days in the month chosen 1 points
Displays day of the week options 0.5 points
Gets day of the week options correctly 0.5 points
Does error checking for ALL input 2 points
Creates calendar correctly
Stores the days in a two-dimensional array 1 points
Stores correct number of days 1 points
Stores days on the correct day of the week 1 points
Displays calendar correctly
Shows correct month 0.5 points
Shows correct year 0.5 points
Shows the header with the days of the week 1 points
Displays the values in the two-dimensional array 1 point
Shows correct number of days 1 points
Shows days on the correct day of the week 1 points
Not enough comments/whitespace -1 point
Output does not match the sample executions given in the assignment -1 point
Bad variable names, method names, and/or class names -1 point