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

581325-0 Introduction to Programming, course examination 17.10.2007/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!

  1. In a biodiesel station there are two diesel oil tanks. Oil can be added only to the main tank, and the customer can get oil only from the main tank. The other tank is a storage tank, which is used, when the capacity of the main tank is no enough. Implement the biodiesel station as a class BiodieselStation.

    Demonstrate the use of class BiodieselStation by a small main method. It is not necessary, not even asked, that this program reads any input.

                                                                        (16 points)
    

  2. What does the concept encapsulation mean in programming? What are the benefits of encapsulation? How is it done in Java? Write also concrete code examples. Maximum length of the answer is 1 sheet of paper, whichs makes 4 pages.
                                                                        (18 points)
    
    

  3. Implement an interactive guessing game: Before the game starts, the game leader inputs 100 integers to the program in random order. All integers are allowed, and also repeating same numbers.

    Then the player starts guessing numbers. S/he tries to guess some of the mumbers the game leader has given. The game ends, when the player has guessed one of the numbers. The result is number of guesses. That is printed by the program.

    You may assume that all the input are valid integers.

    For the sake of efficience you must use the Binary Search in searching the numbers.

                                                                       
                                                                             (16 points)