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. [20pts] Assume the declarations and function definitions below. Fill in the table.
    Note: "error" is a possiblity!
    Note: each question is independent, i.e. no side effects of one expression should be taken to carry over to the next.
    
    string* S = new string[2];
    S[0] = "happy";
    S[1] = "sad";
    
    string foo()
    {
      return "good";
    }
    char bar(string str)
    {
      int i = str.length()-1;
      return str[i];
    }
    bool iscap(char c)
    {
      return (c >= 'A' && c <= 'Z'); 
    }
    
    expressiontype (or error!)value (or error!)
    SN/A
    S[1]
    S[1][2] - 'a' + 'A'
    foo() + 2.5
    S[0][0] = S[1][0]
    bar(foo())
    foo()[3]
    bar(S[0][0])
    iscap(S[0])
    iscap(S[0][0])
  3. [60 pts] Write a program in a file named hw.cpp that reads in information about a series of flights and prints out information about the reverse journey.

    After specifying how many legs are in the trip, the user will type in pairs of airports like ABC->XYZ. Each airport will always be specified by a 3-letter code, separated with ->.

    After reading in information on each leg of the journey, your program should print out the reverse journey in one line with -> between the airport names.

    Example runs:

    ~/$ ./hw
    How many legs? 3
    BWI->JFK 
    JFK->BUF
    BUF->YYZ
    Reverse trip: YYZ->BUF->JFK->BWI
    
    ~/$ ./hw
    How many legs? 1
    DCA->DFW
    Reverse trip: DFW->DCA
    
    ~/$ ./hw
    How many legs? 4
    LHR->ORD
    ORD->OGG
    OGG->NRT
    NRT->BNE
    Reverse trip: BNE->NRT->OGG->ORD->LHR
    
  4. [10 pts] Carefully read the project 2 description and requirements. Honestly declare how you read the project.
    1. (10 pts) I read the project carefully. I have a good understanding of the topics therein.
    2. (10 pts) I read the project carefully, but I don't really understand the following points well:
      
      
      
      
    3. (0 pts) I didn't read the project carefully.
  5. Project 2 is now starting. Please write by hand the honor pledge below and then sign your name. Turn this in with your homework, on a separate sheet of paper:
    The Military Service I am a part of is bound by honor and integrity. I will not compromise our values by giving or receiving unauthorized help on project 2.
    
    
    
    
      
    Name: _____________________________

    Signature: _________________________
Submit to the submission server (due: 0800 on the next class day)
~/bin/submit -c=IC210 -p=hw20 hw.cpp

Bring to class