CS 112a
Fall 2000
Ileana Streinu
Midterm Exam
Thursday, Oct. 19, 2000 8:00 - 10:20am
Write your name and class account on this exam sheet NOW.
Part II: hands-on programming (50 points)
Your friends are also college students, but they do not take
programming classes. They are arguing that they spend more time
than you do on homework assignments. You do not agree, and
decided to research the question. You send out a survey to
all houses on campus, asking each student to report her major
(recorded as an integer code between 0 and 99) and
how much time she spent last week doing her homework (in hours).
The data is collected in a file named data. Each line of
the file contains the integer code of a major and the time
reported by a student.
Your task is to design a program to process and print this
data. The file is read in line by line and you compute, for each
code corresponding to a major (a number between 0 and 99) the
average time spent by a student on homework last week.
When done, you arrange the data in decreasing order of the time
spent by students and print it.
You can reuse any code that you have written so far in this
class. You can write the whole program in one file. You do not
need to use classes for this program, but you should use
struct if appropriate.
To submit:
- A file named mid.cpp containing your code.
- A typescript showing what you have accomplished.
- All submitted by 10:20 as submit Mid.
Last modified October 18, 2000.
Ileana Streinu