Fundamentals of Computer Science I (CSC-151.02 2000F)

Files, Continued


Exercise 0: Preparation

If you have not done so already, please finish the first lab on files.

Scan through, a collection of utilities for reading from files.

Exercise 1: Averaging a line of values

a. Create a file, values, of at least four lines that contains at least two numbers on each line.

b. Using read-line-of-values, write a procedure that opens values, reads each line, computes an average for that line, and prints out the average.

Exercise 2: Dealing with columnar data

Consider the class list, as distributed by the registrar.

a. Write a procedure that reads in the lines of the class list and prints out only the majors. You should use read-line (from our string-library) and substring.

b. Write a procedure that writes a summary of the class year and majors of the students to a file, cs151.summary. Here's some sample (incorrect) contents:

1st:  20
2nd:   5
3rd:   2
4th:  10

UND: 10
GRM:  5
BIO:  1
MAT:  6

Disclaimer Often, these pages were created "on the fly" with little, if any, proofreading. Any or all of the information on the pages may be incorrect. Please contact me if you notice errors.

This page may be found at

Source text last modified Tue Nov 7 10:53:31 2000.

This page generated on Tue Nov 7 10:58:13 2000 by Siteweaver. Validate this page's HTML.

Contact our webmaster at