CS50 Test #2 April 21, 1995 Open book and notes. Answer all questions. 1. (5 minutes) Consider the No Account stack (p 120). Suppose we wanted to add a feature by that would display for the user the number of persons (accounts) that had more than 10 payments remaining and a balance greater than 1000. Describe, in general terms, how you would add that feature to this stack 2. (10 minutes) Develop a script that would accomplish the task described in question 1. 3. (5 minutes) Describe briefly the binary, decimal, and ASCII representations of information, including how each one is related to computers and programs. 4. (5 minutes) Below is an 8-bit binary number. What decimal number does it represent? What ASCII character does it represent? (Show all work in this calculation.) 01111000 5. (10 minutes) Below is an assembly language program. Show all values that will appear in the accumulator while it is executing. [1] LOD 6 [2] ADD 7 [3] ADD 8 [4] STO 9 [5] HLT [6] 4 [7] 2 [8] 5 [9] What would this look like if it were rewritten as a Hypercard script, assuming that locations 6, 7, 8, and 9 were identified as the variables X, Y, Z, and ANS, respectively? 6. (10 minutes) A comparator is a circuit that determines whether two inputs are equal or not, and outputs 1 (true) or 0 (false) accordingly. A one-bit comparator is shown in Figure 6.7 on page 226. a) What are the outputs of all gates in this circuit when its inputs are P=1 and Q=0? b) Describe in general how you would design a two-bit comparator -- that is, one that takes two 2-bit inputs (say P1P2 and Q1Q2) and outputs 1 or 0 depending on whether or not both P1=Q1 and P2=Q2. For instance, its output would be 1 for P1P2=01 and Q1Q2=01, but its output would be 0 for P1P2=01 and Q1Q2=10. 7. (10 minutes) Consider the scene on the back of this sheet. Describe, in terms of basic Jabka objects (spheres, pyramids, etc.), how this particular scene might be modeled. By writing directly on the back of this sheet, indicate what transformations would be needed to give each of these objects the right size and location in the scene. As a point of reference, assume that the pyramid in the scene is centered at the origin (0, 0, 0) and is in the middle of the table. ============================== The scene shown on the back of the test sheet showed a table with four rectangular legs and a pyramid-shaped object sitting on its top. ==============================