Name: ____________________________________________________ Alpha: _____________ Section: ________

Describe help received: _________________________________________________________________

See the bottom for how to submit your work.

Due: Before 0800 on next class day

  1. (10 pts) Read today's lecture notes. Honestly declare how you read the notes.
    1. (10 pts) I read the notes carefully. I have a good understanding of the topics therein.
    2. (10 pts) I read the notes carefully, but I don't really understand the following points well:
      
      
      
    3. (0 pts) I didn't read the notes carefully.
  2. [90pts] Consider the following partial program hw.cpp
    The program is supposed to do as follows:
    1. Read in a file like grades.txt containing m homework grades for n students (each row consists of the m grades for one student).
    2. Print out the scores along with the averages in increasing order of average.
    3. Break the ties by using the last name and then the first name (in the alphabetical order).
    Note that the file states how many students and how many grades per student.
    
    // hw.cpp
    #include "student.h"
    
    int main()
    {
      int n = 0, m = 0;
      Student* stu = readfile(&n, &m);
    
      sort(stu, n, m);
    
      print(stu, n, m);
    
      return 0;
    }
    

    To do:
    • Download hw.cpp.
    • Write the following files so that the program works as the sample run on the right.
      • student.h
      • student.cpp
    • Don't touch hw.cpp at all. You are only allowed to write student.h and student.cpp.
    • Compile your code:
       g++ hw.cpp student.cpp -o hw
    A sample run with user input red.
    ~/$ ./hw
    Filename: grades.txt
    Caitlyn Zoom avg=57.9 67 45 83 38 88 45 23 78 30 82 
    Jake McCrary avg=71.1 89 52 90 67 56 90 95 63 51 58 
    Don Needham avg=71.1 89 52 90 67 56 91 94 63 52 57 
    Edward Needham avg=71.1 89 52 90 67 56 90 95 63 52 57 
    John Poe avg=71.1 90 51 90 67 56 90 95 63 52 57 
    Andy Smith avg=71.9 97 65 63 89 69 84 51 78 68 55 
    Rebecca Wright avg=72.4 76 85 77 95 87 72 64 62 55 51 
    Benjamin Adams avg=73.5 58 96 65 72 93 67 59 74 95 56 
    Jason Rafter avg=74.2 96 66 58 71 87 59 81 78 69 77 
    Aaron Landau avg=76.5 76 97 88 69 64 94 54 75 83 65 
    Thomas Brown avg=81.3 96 67 56 74 94 100 98 68 95 65 
    Julie Jones avg=84.3 88 81 94 59 95 65 98 88 93 82 
    

Submit to the submission server (due: 0800 on the next class day)

~/bin/submit -c=IC210 -p=hw30 student.*
Bring to class