Name: ____________________________________________________ Alpha: _____________________

Describe help received: _________________________________________________________________

  1. [10pts] Given the definitions below, here is code containing four function calls. For each, write the prototype that would match that function call best:
    declarationsfunction calls
    struct Room {
      string bldg;
      string rmnum;
      string type;
      double sqft;
    ifstream fin;
    Room R;
    int N;
    Room *B;
    if (isDoubleOccOffice(R))
  2. [90pts] Your job is to write a program that reads in the file hwin.txt that contains course section data in typical USNA format, then goes into a loop allowing the user to enter queries like "meets M2" that it responds to by printing out all the sections that meet during that day/period. The period entered is one of the regular periods 1,2,3,4,5,6, but half-period overlaps should count. I.e. if the query is "meets T2", and section that meets TR8 should be printed out, even if technically there is only half a period of overlap. A run of the program might look like this
    ~/$ ./prog
    : meets W4
    HE112 4001 MWF4
    HE112 9001 WF9
    SC112 4000 TRF4,W34
    SC112 4040 M4,WF4,T56
    SC112 5534 MTR5,W34
    : meets F6
    : meets T1
    EE301 1111 M1,TR12
    SC112 8812 TR8,W12
    SC112 8012 TR8,F12
    : quit
    To make your like easier, I am gifting you the following function (read the documentation about what the function does for you very carefully but don't bother trying to understand how the function works!):
     Input: pat - a string representing a meeting time, e.g. "MWF2,R34" or "TR9" or "MF5,T65"
            day - a char, one of M,T,W,R,F
            per - an int, one of the regular periods, i.e. 1,2,3,4,5,6
     Output:true if the meeting time in pattern pat overlaps with period day,per, false otherwise
            Ex1 - overlaps("MWF2,R12",'M',8) -> true     overlaps("TR10",'T',4) -> false
    bool overlaps(string pat, char day, int per) {
      bool dflag = false; // day match flag
      for( int i = 0; i < pat.length(); i++) {
        if( pat[i] == ',')
          dflag = false;
        else if( 'A' <= pat[i] && pat[i] <= 'Z' )
          dflag = dflag || pat[i] == day;
        else {
          int q = pat[i] == '1' && i+1 < pat.length() && pat[i+1] == '0' ? 10 : (pat[i] - '0');
          if( dflag && (per == q || (per-1)/2 + 8 == q))
    	return true;
      return false;