Computer Science 1621
Computer Science I

Programming Assignment 4
Conditions and Loops (40 points)
Due Tuesday, November 3, 1998

Introduction

This assignment will provide you with practice both on conditions and loop statements. You should structure your program into procedures and functions performing single functions and test your program one subprogram at a time using drivers.

The Problem

The DatesRUs calendar company has started working on its calendar programs for the coming century, since its current program is out of date, and they want to hire you. They want you to produce a program that prompts a user for a month (entered as a number between 1 and 12) and a year (entered as a number between 2000 and 2099) and then have the program print out a calendar for that month in that year. Samples of the output of the program are shown below:

-------------------------------------------------
Welcome to the DatesRUs Calendar 2000 program!

This program will prompt you for a month and year
and will print a calendar for that month.  To
enter the month you will type a number between
1 and 12 representing the months January (1),
February (2), March (3) and so on.  The year
must be a number between 2000 and 2099.


Enter month (1-12) of calendar to print: 1
Enter year (2000-2099) of month to print: 2000

January 2000
  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 29
 30 31
-------------------------------------------------

-------------------------------------------------
Welcome to the DatesRUs Calendar 2000 program!
 
This program will prompt you for a month and year
and will print a calendar for that month.  To
enter the month you will type a number between
1 and 12 representing the months January (1),
February (2), March (3) and so on.  The year
must be a number between 2000 and 2099.
 
 
Enter month (1-12) of calendar to print: 12
Enter year (2000-2099) of month to print: 2099
 
December 2099
  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 29 30 31
-------------------------------------------------
 
-------------------------------------------------
Welcome to the DatesRUs Calendar 2000 program!
 
This program will prompt you for a month and year
and will print a calendar for that month.  To
enter the month you will type a number between
1 and 12 representing the months January (1),
February (2), March (3) and so on.  The year
must be a number between 2000 and 2099.
 
 
Enter month (1-12) of calendar to print: 2
Enter year (2000-2099) of month to print: 2096
 
February 2096
  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 29
-------------------------------------------------
 
-------------------------------------------------
Welcome to the DatesRUs Calendar 2000 program!
 
This program will prompt you for a month and year
and will print a calendar for that month.  To
enter the month you will type a number between
1 and 12 representing the months January (1),
February (2), March (3) and so on.  The year
must be a number between 2000 and 2099.
 
 
Enter month (1-12) of calendar to print: 13
Please use a number between 1 and 12!

Enter month (1-12) of calendar to print: -1
Please use a number between 1 and 12!
Enter month (1-12) of calendar to print: 0
Please use a number between 1 and 12!
Enter month (1-12) of calendar to print: 7
Enter year (2000-2099) of month to print: 20000
Please use a number between 2000 and 2099!
Enter year (2000-2099) of month to print: 1996
Please use a number between 2000 and 2099!
Enter year (2000-2099) of month to print: 2001
 
July 2001
  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
 29 30 31
-------------------------------------------------

Program Notes

Since your program will be heavily modularized, be sure to test each procedure individually as you progress.

What To Hand In

Hand in a full lab report for your program. For your tests you should show the enough different combinations of month and year to conclude that your program produces the correct output for all of the month and year combinations.

EXTRA CREDIT (New)

2 extra points - make your calender work correctly for the years 1900-2499.

5 extra points - when the user types 0 for the month, print out a calendar for the entire year with three columns of months (and four rows). The format of the full year calendar would be:

				2000

	 Jan			Feb		       Mar
 S  M Tu  W Th  F  S    S  M Tu  W Th  F  S    S  M Tu  W Th  F  S
                   1          1  2  3  4  5             1  2  3  4
 2  3  4  5  6  7  8    6  7  8  9 10 11 12    5  6  7  8  9 10 11
 9 10 11 12 13 14 15   13 14 15 16 17 18 19   12 13 14 15 16 17 18
16 17 18 19 20 21 22   20 21 22 23 24 25 26   19 20 21 22 23 24 25
23 24 25 26 27 28 29   27 28 29               26 27 28 29 30 31
30 31
	 Apr			May		       Jun
 S  M Tu  W Th  F  S    S  M Tu  W Th  F  S    S  M Tu  W Th  F  S
                   1       1  2  3  4  5  6                1  2  3
 2  3  4  5  6  7  8    7  8  9 10 11 12 13    4  5  6  7  8  9 10
 9 10 11 12 13 14 15   14 15 16 17 18 19 20   11 12 13 14 15 16 17
16 17 18 19 20 21 22   21 22 23 24 25 26 27   18 19 20 21 22 23 24
23 24 25 26 27 28 29   28 29 30 31            25 26 27 28 29 30
30
	 Jul			Aug		       Sep
 S  M Tu  W Th  F  S    S  M Tu  W Th  F  S    S  M Tu  W Th  F  S
                   1          1  2  3  4  5                   1  2
 2  3  4  5  6  7  8    6  7  8  9 10 11 12    3  4  5  6  7  8  9
 9 10 11 12 13 14 15   13 14 15 16 17 18 19   10 11 12 13 14 15 16
16 17 18 19 20 21 22   20 21 22 23 24 25 26   17 18 19 20 21 22 23
23 24 25 26 27 28 29   27 28 29 30 31         24 25 26 27 28 29 30
30 31
	 Oct			Nov		       Dec
 S  M Tu  W Th  F  S    S  M Tu  W Th  F  S    S  M Tu  W Th  F  S
 1  2  3  4  5  6  7             1  2  3  4                   1  2
 8  9 10 11 12 13 14    5  6  7  8  9 10 11    3  4  5  6  7  8  9
15 16 17 18 19 20 21   12 13 14 15 16 17 18   10 11 12 13 14 15 16
22 23 24 25 26 27 28   19 20 21 22 23 24 25   17 18 19 20 21 22 23
29 30 31               26 27 28 29 30         24 25 26 27 28 29 30
                                              31