CS1711 Lab 7 - November 10 and 12, 1998
More on Streams

Streaming the calendar

This lab is an exercise in updating a program to use new code and to change from interactive to file I/O. You should find the lab quite quick to complete. If you have time left it is a good opportunity to work on the next programming assignment.
  1. Obtain the file from the directory for Lab 7. It is a solution to a calendar program problem similar to Assignment 3.
  2. Compile and run the program to verify that it performs as required.
  3. There are two sets of modifications to the program which are required. The first involves loops and the case construction.
  4. Examine all of the loops in the program. Notice that thay have been implemented without using the counted loop (the for loop). Change as many of these loops as possible to for loops. If you cannot change a loop be prepared to explain why not to the instructor.
  5. Examine all of the branches (if statements) in the program. Wherever possible replace a branch, or a sequence of branches, with a switch statement.

The second set of modifications will change the program from an interactive program to one which uses files.

  1. Replace the prompt to the user for the year and starting day of the year with a request for file names from which to read input, and to which to write the calendar. (An example of this technique is in the text.)
  2. Modify the program so that it will read the year and starting day from the first two lines of the input file specified by the user.
  3. Modify the program so that it will write the calendar for the year to the output file specified by the user.
  4. Demonstrate your modified program to the lab instructor.