FINAL EXAMINATION Version 1A (200 points max)
Hand in your final project before starting this final. Print your name and Student Id number on the back of the last sheet. Closed book, one (8.5><11") open sheet of notes. Calculator OK. No wireless communication or computers. Write answers and working on this paper. Credit is given for working and incomplete answers. Attempt every question (10 Questions, 1 per page).
1.(24 points)
a. (12 points) The following C++ program compiles and runs. I compile it into an executable program called puzzle and run it on a UNIX system. Write what it outputs in the box provided on the right when I run it with this command:
b. (12 points). Here is a function f(int i) and a main program. Work out, carefully, what the program outputs when run. Do not guess!
2. (10 points) The following class will be used in several questions. Draw a diagram, using the UML, of the class below. Show all attributes, operations, data types, and visibility(+,#,-), but no stereotypes.
3.(22 points) More Puzzle.... Fill in the blanks (2 points each).
a.(6 points) The default constructor ....
b.(6 points) The other constructor for ....
c. (10 points) This function ...sends .... to the standard output cout, ...
4(24 points) More...
a.(12 points) The other member function ... also outputs data. It is given the name of a file. It opens the file for output, and puts ...., and then closes the file. Complete the code below.
b.(12 points max) Here are four algorithms that work on a sequential container of items:
...
(Put letters below. A wrong letter can score -1 point, but the right A, B, C, D can score 2 points)
5. (24points) Yet More on...
a. (6 points, 2 points a blank ) Complete the code in ... using a standard algorithm to ...
b. (8 points, 2 points per blank) Complete the code below using C++ exception handling:
#include <stdexcept>
c.(8 points) Complete the main program below that tests ...
6. (20 points max, blank answer = wrong=0 points, correct=2 point, near miss=1 point) STL.
a. (14 points)For each situation below, write down the single answer that fits the situation or description best:
Answers: array, deque, list, map, queue, set, stack, vector
b.(6 points) Fill in the blanks in the following program so that ... Read the whole program and think before writing your answers. Note. This was a working program before I blanked out three things below. What were they?
7. (24 points). Here is the design for a parametrized class called a Link. It is used for implementing stacks, queues and other data structures.
...
a. (12points, 2 points max per blank, no answer=0 ) Fill in blanks ______ in the code below.
b.(12 points). Study the main program below that uses Link and work out what appears on the screen when the program below is run. Use the space on the left for working. It can earn points Erase nothing, cross out changed values. No points for tidiness. You may add arrows if you wish.
8. (24 points)
8a. (12 points). Draw a class diagram of the following classes using the UML showing classes and generalization, attributes, operations, and access modes (+,#,-).
8b. (12 points MAX, 1 point per correct answer, blank=0). In a main program that includes the above declarations I add the following declarations: ... Mark the statements that will compile with "OK" and those that the compiler will reject with "NO". (1 pt each, 3 errors allowed).
9.(18 points) inheritance and polymorphism
a. (6 points) True or False? Circle the correct T|F choice (blank=wrong=0, correct T/F 1point)
b. (12 points) Work out what is output by the following useless but correct program (1 point for each correct output, 0 if blank, missing, or wrong)
10.(10 points). Use the Unified Modeling Language (UML) to draw a diagram of the classes and relationships in the last programming project. You can omit some attributes and operations if the full diagram does not fit below. Grading: Correct use of UML -- 5 points, Matching project handed in -- 5 points.