TIE 120 Programming (summer 2001)
Take-home midterm examination
2001-06-15/25

Koe suomeksi / in Finnish

The examination ends at 2001-06-25T16:00 Finnish local time. You must have submitted your solutions to the problems to the lecturer by then.

Use a computer when preparing your solutions. Please put an answer to only one problem in one file.

Send your solutions by email to gaia+vk@iki.fi. Please put your name and your personal identity number (henkilötunnus) to the subject of the message. Attach the files that contain your solutions to the message. You can send it in several pieces and you may even revise your already sent-in solutions - only the latest ones will be considered. You will receive an automatic acknowledgement message when your solutions have been received.

The examination includes a mandatory private oral feedback session. It will be held after the solutions have been graded. The time and place will be announced later.

You are allowed to use any sources whatsoever. You may collaborate and you may ask for advice. However, the solutions you turn in must be entirely your own work. You may collaborate for example in digging out information and in figuring out the idea of the solution.

The programming problems must be solved using the C++ language. All means provided by the international (ISO/ANSI) standard may be used. Other means than those provided by the international standard may not be used. (If you are not sure whether something is sanctioned by the standard, mention that in your solution.) Wherever possible, use C++-specific means instead of the traditional means provided by C (for example, new instead of malloc, cout instead of printf, string instead of char [] or char * and so on).

The examination incudes essay problems. An essay is a piece of writing, and like any other kind of writing, it should be a good presentation of the subject matter (and not wander off the topic). An essay has a beginning and an end, and between them there should be a smooth progression of arguments and information. In an essay problem, it is more important to analyze the connections between things and causes and effects than to present specific facts. You should concentrate on bringing out your own thoughts (although they should be linked with the facts of the issue) instead of merely quoting or paraphrasing the sources. It is also beneficial to use examples and drawings.

In all solutions, explain briefly which sources and whose advice you have used and how.

Remember that even an inadequate solution may give you some points. Also remember that it is of no use to make a too extensive solution: there are only so many points that can be awarded to a solution.

Solve all the problems.

Problems

  1. a) Write a short essay on the differences between the container classes provided by the STL. (8 p.)

    b) Write a small program that counts how many times each word is used in a file whose name is given on the command line. Define yourself what a word is exactly. (4 p.)

  2. Your assignment is to write a class for a bank account. It should be able to remember the balance of the account. There will be deposits and withdrawals both in Finnish marks and in euros. The account class must be able to answer to the question "What is your balance" in both marks and euros. There must also be a possibility for money transfers between accounts. There is no credit associated with the account, so the balance can never be negative.

    Note that the class must not print or ask the user anything. It should communicate with the world only via the parameters and return values of its methods. Also note that the point here is to create a class, not a program.

    a) Design the class. In other words, think of which attributes, constructors and methods it needs. Does it need assisting classes? If it does, design them too. Don't get carried away too much, though. Draw a data structure diagram and either CRC cards or a UML class diagram on your design. (4 p.)

    b) What kind of exceptional circumstances can manifest themselves? How are they handled? (1 p.)

    c) Write a simple main program for testing purposes.(1 p.)

    d) Implement your design. (6 p.)


Antti-Juhani Kaijanaho
Last modified: Fri Jun 15 09:31:01 EEST 2001