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

581325-0 Introduction to Programming, course examination 16.10.2006/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. Explain shortly and clearly the following concepts: the type of a variable, parameter, encapsulation, toString()-method, index.
                                                                (18 points)
    

  2. A juice automata has two tanks: one for water and one for concentrated juice. Juice is produced by mixing 1/10 concentrated juice with 9/10 water.

    Implement the juice automata as a class JuiceAutomata. (The constructor and accessors interpret negative parameter values as zero.)

    Program also a main method to show, how the constructor and the methods are used.

                                                               (16 points)
    

  3. Make a program that first asks the amount of integer numbers to be input, then asks that amount of numbers one by one and assingns them into an array. After this the program provides the following service:

    The program is given an integer one by one, and the program finds out, whether that integer is to be found in the array. You must use the Binary Search for finding the answers. All the input numbers should be in the range 1-100000, except the number 0, which ends all the questioning.

    You may assume that all the input are valid integers, but their values must be checked and possible must be errors reported.

                                                                (16 points)