University of Helsinki / Dep. of Computer Science / Introduction to Programming / Copyright © 2003 Arto Wikla.

581325-0 Introduction to Programming, course examination 14.11.2003/AW

Write the name of the course, the date of the exam, your name, personal number and signature on each paper. Write each answer on a separate paper! You are allowed to use the tools of the Lue-class (or Read-class) for reading the input.

  1. Answer the following questions briefly and exactly:
                                                                (10 points)
    

  2. A certain granary comprises of two grain silos. Only the first silo has a loading platform. Grain can be moved from one silo to another.

    Create class Granary to implement the functionality of the granary described above.

    (The constructor and accessors interpret negative parameter values as zero)

    Don't implement the silos as TinyStore-objects!

                                                                (14 points)
    
  3. "What in the world are those method things?" , your friend wails when hearing your stories of the course Introduction to Programming. Your friend has programmed enough to know simple variables, expressions and statements. "What the heck are 'parameters', who is 'calling' and whom, why?, he goes on in despair. Help your friend understand what it is all about. Draw up a written description (1 exam paper at the most). Keep in mind that examples aid learning. In the evaluation of your answer, we will take into account the intended reader of the description, so do not write for the examinator, who already knows about it, but for that friend!
                                                                (12 points)
    

  4. Implement the following guessing game as an interactive program. Before the game starts the game leader inputs 100 integers into the program in random order. Then the player starts to use the program. The player tries to guess the numebers that the game leader has input in the computer. The game ends, when the player has guessed three different numbers. The result is the number of guesses, so it is at least three.

    You may assume that the game leader really inputs 100 different numbers. For the sake of efficiency, the search for guessed numbers must be programmed with the Binary Search

                                                                (14 points)