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. [10pts] Assume the following declarations and fill in the table with either the type of the given expression, or "error" if appropriate.
    
    struct Point
    {
      double x, y;
    };
    
    struct Trial
    {
      double stime, etime;
      Point* ways;
      int numways;
    };
    
    struct Subject
    {
      string name;
      int id;
      Trial pre, post;
    };
    
    Subject S;
    Subject* A;
    int i, j;
     
    expressiontype
    S.id
    A[i]
    A.pre.ways[i][j]
    S.post = A[i].pre;
    A[i].post.ways
    S.pre.ways[i]
    A[i].id = S.ways[i].y
    A[i].pre.ways[j].x
    A[i].post.ways.x
    S.pre.numways++
  3. [80 pts] Download hw.cpp.
    The program is supposed to work as follows:
    • It reads a data file containing offerred course sections like sections.txt.
    • Then, it allows the user to search for sections based on a course name, or a section number.
    On the right is a sample run (with user input in red).

    Your task:

    1. Read the starter code hw.cpp carefully and understand what each function does or should do. (You may want to refer to the course notes on pass-by-address and sorting-and-search).
    2. Add code in hw.cpp so that the program works correctly.
    3. Don't touch the main function given in the starter code.
    ~/$ ./hw
    Filename: sections.txt
    >  course EE301
    EE301 1111 M1,TR12
    EE301 2222 M2,WF12
    EE301 5555 M5,TR56
    
    >  section 4040
    SC112 4040 M4,WF4,T56
    
    >  course EE327
    EE327 3333 MWF3,R34
    
    >  section 3333
    EE327 3333 MWF3,R34
    
    >  quit
    
    sections.txt
    N = 17
    HE112 1001 MWF1
    HE112 1002 MRF1
    HE112 2001 T2,R12
    HE112 4001 MWF4
    HE112 9001 WF9
    HE112 5001 MWF5
    HE112 6001 MWR6
    EE301 1111 M1,TR12
    EE301 2222 M2,WF12
    EE301 5555 M5,TR56
    EE327 3333 MWF3,R34
    SC112 3000 M3,WF3,T34
    SC112 4000 TRF4,W34
    SC112 4040 M4,WF4,T56
    SC112 5534 MTR5,W34
    SC112 8812 TR8,W12
    SC112 8012 TR8,F12
    

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

~/bin/submit -c=IC210 -p=hw28 hw.cpp
Bring to class