CprS 157 Schedule
CprS 157 Class 10
CprS 157 Class 12

Additional Control Structures
Chapter 9 - Class 11

Reading Some Sample Programs

// Rainfall program
// This program inputs 12 monthly rainfall amounts from a
// recording site and computes the average monthly rainfall.
// This process is repeated for as many recording sites as
// the user wishes.

Program rainfall illustrates the use of the do ... while ... construct for controlling iteration. It also illustrates how to include loop invariants as comments in your code to help yourself and others verify its correctness.

Programming Exercises

  Solve these exercises in class, to your own satisfaction. If called for, create the appropriate data files and test your program on your data. Demonstrate your solutions to the instructor or to the class TA. There is nothing to hand in from this activity.

Homework For Chapter 9

  Countless real world computing applications require manipulations of a database. We are going to break into that world today, in a small way, by writing a program which performs a transformation on a database. It steps through an input file, line-by-line, transforms the data contained on each line, and writes that transformed data to an output file. In this case the transformation is pretty simple: people's names are transformed into their initials. Read the program's specification carefully, develop a logical outline of the algorithm you will use to solve the problem, and then write a clear, elegant, and correct implementation of your solution. Programming is a creative effort that calls for a thoughtful balance of artistic and technical skills. Put on some good background music and enjoy!