University of Ottawa
School
of Information Technology and Engineering

 

CSI1102: Lab Assignment #3

 

Due to be marked in your scheduled lab time during the week of March 14, 2005.

 

 

1-     Roll Die [10pts]

Implement an application that rolls a six-sided die 100 times and displays the frequency that each side obtained, along with a histogram:

 

 

Note that Side, Frequency and Histogram are in Bold using the Courier font and with a size 12.

Tools to be used include arrays, JTextArea, as well as JOptionPane.showMessageDialog.

(Information can be found on http://www.javadoconline.com/)

 

 

2-     BorderLayout [10pts]

Using the BorderLayout extended from JFrame to manage the content pane in 5 regions: North, South, East, West, and Center, implement an application so that if one of the regions is hidden (only one can be hidden at a time) the rest of the regions expand as shown below:

 

 

 

 

Use buttons for the regions and a Container to set up your layout with a size of 300x200.

Make sure to use arrays and to implement ActionListener for your events and learn more on: Container, getContentPane, addActionListener, setLayout, layoutContainer, setSize and actionPerformed on the site already mentioned.

 

3-     Account [10pts]

Implement a set of classes in such a way that one of them provides services such that an account can initially exist with or without any amount of money in it; if a deposit is made it updates the current balance; the balance can be obtained upon request and when a withdrawal is made it checks for sufficient funds, in which case it updates the account balance or denies the withdrawal by displaying the following message: "Insufficient funds: Withdrawal denied!". Another class, taking advantage of properties offered by the first class, will deal with the different type of interest that an account may carry; its services will cover accounts with balances that have a default interest rate of 2.5%, accounts with balances having specific interest rates, accounts with empty balance and the default interest rate; balances will be updated with monthly interest. The driver program will create a set of instances for the following cases: an account with an empty balance and default interest, an account with a balance of $250 and a default interest, and finally an account of $300 at an interest of 8.7%. The account with no money will then make a deposit of $150 and a message will be displayed showing its new balance. The accounts with $250 and $300 will respectively make withdrawals of $280 and $15. Assume that a month has passed; display a message for each account showing their respective new balance.