Date Assigned: Monday, March 5, or Tuesday, March 6, 2007.
Due Date: Monday, March 19, or Tuesday, March 20, 2006,
before the beginning of your lab section.
Objective: The main objective of this assignment is to learn to
design user-defined methods.
Programming assignment: to help compute average grades and
student GPAs,
- write a method that, given a name of the file
with numbers, computes the average of all these numbers, and
- write a program that uses this method.
Test your program
on an example of a simple file with 2 or 3 numbers.
Hint:
- first, create a reader to read from the given file;
- read the records (numbers) one by one; as you read each number, add this
number to the sum-so-far, and add 1 to the counter
(number of records read so far);
- compute the average by dividing the sum of all the records
by the total number of these records.
For extra credit: programming assignment 4 from p. 438 of the
book.
Homework assignment: on a separate sheet of paper, solve Ex. 2,
4, and 8 at the end of Chapter 7 (on pp. 429 and 431).
Deliverables: as instructed by your TA.