COSC 120
Lab # 7

Prelab assignment

The prelab work is to be done before you go to the lab.

  1. Read pages 135 - 139.
  2. Do the prelab assignment on pages 141 - 142, exercises 1 - 3. There is an error in Exercise 2: program Demo is on page 137, not on page 135 as indicated by the lab manual.
  3. Do Lesson 7-1, exercises 1 - 3 to check your answers on the prelab assignment.
  4. As soon as you enter the lab, turn in your completed prelab work to the instructor who will initial it and return it to you. You will attach it to your other materials upon completing the lab.

Lesson 7-2 page 144 - 145

  1. Copy Shell1.cpp from Chapter 7 of the K drive to your C drive.
  2. Do exercise 1.

  3. When documenting functions in the lab, follow the lab manual's style; include a brief description, preconditions, and postconditions.
  4. Print your modified Shell1.cpp, you will be turning it in.
  5. Skip exercise 2.
  6. Close the workspace.

Lesson 7-3 page 146 - 147

Hint: Write the following helper function that prints numb characters ch.
       void DrawChars(int numb, char ch);
There's no reason that ch can't be the space character, is there?
  1. Copy Shell2.cpp from the K drive to your C drive.
  2. Do exercise 1. The end-of-file character can be generated by simultaneously pressing either the Ctrl and 'D' keys or the Ctrl and 'Z' keys on the keyboard.
  3. Print your modified Shell2.cpp, you will be turning it in.
  4. Do exercise 2.
  5. Rerun your program using 4, 10, and 7 as the input values.
  6. Print your modified Shell2.cpp, you will be turning it in.
  7. Do exercise 3.
    Hint: Since the while loop in main() is looking for the EOF character, prompt for and read the border symbol at the top (inside) of the loop.
  8. Print your modified Shell2.cpp, you will be turning it in.
  9. Close the workspace.

Lesson 7-4 pages 148 - 149

Hint: The sample program on pp. 137 - 138 of the prelab reading will be very helpful for these exercises.
  1. Copy Shell3.cpp from the K drive to your C drive.
  2. Do exercises 1 - 3.
  3. Print your modified Shell3.cpp, you will be turning it in.
  4. Skip exercises 4 - 7.
  5. Close the workspace.

Finally,

  1. Exit C++ and logout.
  2. Assemble your materials to be turned in:
  3. Staple your materials neatly, in the above order. Leave them on the table at the front of the room. Make sure your name is on each page.

Last modified: TAA 4:45 pm October 29, 2001