Free University of Bolzano/Bozen
Faculty of Computer Science - Bachelor in Applied Computer Science
Bachelor in Production Engineering
Introduction to Programming - A.A. 2005/2006

Exercise 6

Midterm Simulation and Conditional Statements


Exercise 6A (Midterm Simulation)

We want to realize a program to handle a document archive. For each document the following information is stored: name of the author, title of the document, and number of available copies.

Part 1. Write a class Document that implements the following methods:

An example program that uses class Document is given: TestDocument.java

Part 2. Write a class UseDocument, client of Document, that contains the following public static methods:

An example program that uses class UseDocument is given: TestUseDocument.java

Solutions: Document.java, UseDocument.java



Exercise 6B (Conditional Statements)

Design and implement a class ExchangeMachine. The class should model an exchange cash dispenser that accepts Dollar bills and provides Euro bills applying pre-set exchange rates (dependent on the amount of money to be changed).

We're interested in the following features:

The Euro/Dollar exchange rate is defined as the amount of Euros corresponding to one Dollar:
0.5 if the exchanged amount is less than 10 dollars,
0.9 if the exchanged amount is between 10 dollars and 100 dollars and
1.0 if the exchanged amount is more than 100 dollars.

Solution: ExchangeMachine.java