Computer Science 1511
Computer Science I

Programming Assignment 5
Conditions and Loops (35 points)
Due Thursday, November 11, 1999

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 decided to write a calendar program to generate calendars for years between 1800 and 2399. 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 1800 and 2399) 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 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 1800 and 2399.


Enter month (1-12) of calendar to print: 1
Enter year (1800-2399) of month to print: 1800

January 1800

Sat  4 11 18 25 
Fri  3 10 17 24 31 
Thu  2  9 16 23 30 
Wed  1  8 15 22 29 
Tue     7 14 21 28 
Mon     6 13 20 27 
Sun     5 12 19 26
-------------------------------------------------
Welcome to the DatesRUs Calendar 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 1800 and 2399.


Enter month (1-12) of calendar to print: 2
Enter year (1800-2399) of month to print: 1900

February 1900

Sat  3 10 17 24 
Fri  2  9 16 23 
Thu  1  8 15 22 
Wed     7 14 21 28 
Tue     6 13 20 27 
Mon     5 12 19 26 
Sun     4 11 18 25
-------------------------------------------------
Welcome to the DatesRUs Calendar 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 1800 and 2399.


Enter month (1-12) of calendar to print: 3
Enter year (1800-2399) of month to print: 2001

March 2001

Sat  3 10 17 24 31 
Fri  2  9 16 23 30 
Thu  1  8 15 22 29 
Wed     7 14 21 28 
Tue     6 13 20 27 
Mon     5 12 19 26 
Sun     4 11 18 25
-------------------------------------------------
Welcome to the DatesRUs Calendar 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 1800 and 2399.


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: 13
Please use a number between 1 and 12!
Enter month (1-12) of calendar to print: 15
Please use a number between 1 and 12!
Enter month (1-12) of calendar to print: -2
Please use a number between 1 and 12!
Enter month (1-12) of calendar to print: 12
Enter year (1800-2399) of month to print: 2400
Please use a number between 1800 and 2399!
Enter year (1800-2399) of month to print: 0
Please use a number between 1800 and 2399!
Enter year (1800-2399) of month to print: 239 9
Please use a number between 1800 and 2399!
Enter year (1800-2399) of month to print: Please use a number between 1800 and 2399!
Enter year (1800-2399) of month to print: 2399

December 2399

Sat  4 11 18 25 
Fri  3 10 17 24 31 
Thu  2  9 16 23 30 
Wed  1  8 15 22 29 
Tue     7 14 21 28 
Mon     6 13 20 27 
Sun     5 12 19 26
-------------------------------------------------

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

(7 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
         April                August               December       
Sat  1  8 15 22 29    Sat  5 12 19 26       Sat  2  9 16 23 30    
Fri     7 14 21 28    Fri  4 11 18 25       Fri  1  8 15 22 29    
Thu     6 13 20 27    Thu  3 10 17 24 31    Thu     7 14 21 28    
Wed     5 12 19 26    Wed  2  9 16 23 30    Wed     6 13 20 27    
Tue     4 11 18 25    Tue  1  8 15 22 29    Tue     5 12 19 26    
Mon     3 10 17 24    Mon     7 14 21 28    Mon     4 11 18 25    
Sun     2  9 16 23 30 Sun     6 13 20 27    Sun     3 10 17 24 31 

         March                 July                November       
Sat  4 11 18 25       Sat  1  8 15 22 29    Sat  4 11 18 25       
Fri  3 10 17 24 31    Fri     7 14 21 28    Fri  3 10 17 24       
Thu  2  9 16 23 30    Thu     6 13 20 27    Thu  2  9 16 23 30    
Wed  1  8 15 22 29    Wed     5 12 19 26    Wed  1  8 15 22 29    
Tue     7 14 21 28    Tue     4 11 18 25    Tue     7 14 21 28    
Mon     6 13 20 27    Mon     3 10 17 24 31 Mon     6 13 20 27    
Sun     5 12 19 26    Sun     2  9 16 23 30 Sun     5 12 19 26    

       February                June                 October       
Sat  5 12 19 26       Sat  3 10 17 24       Sat  7 14 21 28       
Fri  4 11 18 25       Fri  2  9 16 23 30    Fri  6 13 20 27       
Thu  3 10 17 24       Thu  1  8 15 22 29    Thu  5 12 19 26       
Wed  2  9 16 23       Wed     7 14 21 28    Wed  4 11 18 25       
Tue  1  8 15 22 29    Tue     6 13 20 27    Tue  3 10 17 24 31    
Mon     7 14 21 28    Mon     5 12 19 26    Mon  2  9 16 23 30    
Sun     6 13 20 27    Sun     4 11 18 25    Sun  1  8 15 22 29    

        January                 May                September      
Sat  1  8 15 22 29    Sat  6 13 20 27       Sat  2  9 16 23 30    
Fri     7 14 21 28    Fri  5 12 19 26       Fri  1  8 15 22 29    
Thu     6 13 20 27    Thu  4 11 18 25       Thu     7 14 21 28    
Wed     5 12 19 26    Wed  3 10 17 24 31    Wed     6 13 20 27    
Tue     4 11 18 25    Tue  2  9 16 23 30    Tue     5 12 19 26    
Mon     3 10 17 24 31 Mon  1  8 15 22 29    Mon     4 11 18 25    
Sun     2  9 16 23 30 Sun     7 14 21 28    Sun     3 10 17 24