CS 135: Computer Science I
Spring 2008
Design, implement, and test a complete C/C++ program that uses a while loop and reads ten (
) first names and ages from a file
("names.txt") and finds the minimum, maximum, and average age of
the people listed in the file. Your program should print the following
information to standard output.
Suppose "names.txt" contains
John 78 Jane 89 pat 56 sarah 23 foo 3 bar 55 connor 101 matt 23 clark 78 lois 21
Then your program's output may look like:
Name: John Age: 78 Name: Jane Age: 89 Name: pat Age: 56 Name: sarah Age: 23 Name: foo Age: 3 Name: bar Age: 55 Name: connor Age: 101 Name: matt Age: 23 Name: clark Age: 78 Name: lois Age: 21 ============================================= Youngest person is: foo and their age is: 3 ============================================= The average age is: 52.7 ============================================= Oldest person is: connor and their age is: 101 =============================================
Note that the output is not aligned very well. You may use the prettyPrint functions to produce better looking output.
Modify the red blood cell counting and diagnosis program from
assignment five to use a for loop and read the names of the
exactly ten (
) files containing subject data from a file named
"subjectFilenames.txt", and produce a diagnosis report that is
written to the file "diagnosis.txt". For each subject file, your
program should print the name of the subject file being processed to
standard output. If "subjectFilenames.txt" contains
1 :
data/subject0.txt data/subject1.txt data/subject2.txt data/subject3.txt data/subject4.txt data/subject5.txt data/subject6.txt data/subject7.txt data/subject8.txt data/subject9.txt
Then your output (to standard output) should look like:
Processing subject filename: data/subject0.txt Processing subject filename: data/subject1.txt Processing subject filename: data/subject2.txt Processing subject filename: data/subject3.txt Processing subject filename: data/subject4.txt Processing subject filename: data/subject5.txt Processing subject filename: data/subject6.txt Processing subject filename: data/subject7.txt Processing subject filename: data/subject8.txt Processing subject filename: data/subject9.txt
And your output file "diagnosis.txt" can be seen on the assignment's web page.
Turn in a Folder (Binder) containing:
Ask an instructor or TA if you have questions.
This document was generated using the LaTeX2HTML translator Version 2002-2-1 (1.71)
Copyright © 1993, 1994, 1995, 1996,
Nikos Drakos,
Computer Based Learning Unit, University of Leeds.
Copyright © 1997, 1998, 1999,
Ross Moore,
Mathematics Department, Macquarie University, Sydney.
The command line arguments were:
latex2html -split 1 as7S08
The translation was initiated by Sushil Louis on 2008-03-09