Programming assignment
Write a program that takes as input two numerals representing
a month (January is represented by 1) and a year, and then prints a
calendar for the month in the year specified.
- If 1 <= month <=12 and year >= 1 then
the calendar is displayed with the name of the month and year on one
line, the days of the week below, and finally the layout of the days of
the month. For example if the input were 2 2006, then we expect output
similar to the output of cal on a Unix
system:
February 2006
S M Tu W Th 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
- If month <1, month > 12, or year <= 0
then output the following:
INVALID INPUT
X X X X X X X
? ? ? ? ? ? ?
? ? ? ? ? ? ?
? ? ? ? ? ? ?
? ? ? ? ? ? ?
? ? ? ? ? ? ?
To print the calendar the program
needs to determine the name of the month and that can be derived by
converting the month number to the appropriate string. The year comes
from input. The program needs to determine the day of the week for the
first of the month. Use the techniques mentioned in problem 4 on page
pages 415.
- Note that the formula on page 415 should be dayOfWeek
=int(JDN +1.5) %7 according to the information at http://mathforum.org/library/drmath/view/54374.html.
Alternatively you can change the constant in the formula
on page 416 to 1720994.5. It has the same effect.
- I'm expecting to see the program contain at least five
functions:
- A function that returns the name of a month given the
month number
- A function that returns a numeral indicating the day of a
week on which a date occurred/occurs given the month, day, and year as
input.
- A function that returns True if a year is a leap year and
False if not.
- A function that returns True if the input is valid and
False if not.
- A function that prints a calendar for a month and year.
The program verifies the month and year are valid, before the function
is called.
- Input comes stdin. Output goes to stdout. No prompting for
input, and no output other than what is specified above.
Assignment is Due
Wednesday, March 15, 2006. Deliverables:
- A completed project analysis: It’s always best to
put thought into the design of the project BEFORE you begin typing. For
this assignment you re required to complete a project analysis before
the assignment is due. The project analysis is due March 1, 2006,
with 5 points deducted from your total score for the project for each
day it is late. To complete the project analysis sheet, copy the file:
~ernie/220/prj2.txt. Read through the questions and write appropriate
answers for your program.
- A link to the source file
- A link to a script file showing the compilation and
execution of the program
- A link to a file containing the results of running your
program with the following inputs.
02 2004
02 2006
02 2000
02 1900
5 2006
12 1980
13 2006
0 2005
-5 123
12 123
2005 2
13 2006
2 1580
2 1581
2 1582
2 1583
5 1945
5 2945
5 45
5 999999
1 0
10 1492
07 1776
Some warmups
p513 # 12,p 514 #5, p 515 #10, 11
Abstract Data Types, OOP, Classes
Take a look at Time class in Chapter 11
P580 #5, P581 #8, p582 #13, #14, #15, P583 #14

This work is licensed under a Creative
Commons License.
Ernest
Ackermann Department
of Computer Science, Mary
Washington College
CPSC 220 | CPSC 401
Bibliographic Information:
.