CS 157 Spring 2002                Assignment 8 – Object Oriented Programming – Using an Existing Class      100 points

Assigned: 03/21/2002

Due: 04/04/2002 at the start of class  (that seems like a long way off, but Easter break is in there with no lab on 3/29)

 

Pre-Lab (Do Before Lab):  Bring a new disk. Plan out sequence of statements needed for program. This is another step up in complexity. Plan ahead!!

 

Main Assignment:

We are writing a simplified ATM simulation. The (revised) simplified account class has been provided (under assignments on my WWW page). To keep things simple, we will only have one account at our bank (We don’t cover “arrays” until Chapter 6). Your task is to create a main program that does: 1) setup work; 2) some number of days of processing; and 3) final reporting.

The setup work must set up an account via asking a user (probably a bank IT worker) for info such as the account number, PIN, initial balance and interest rate. The initial balance and interest rate should be validated. The set up work also asks the user for how many days the simulation is to run.

The daily processing is somewhat simplified since we don’t actually have an ATM machine at our disposal. Instead, for each day, we will always have 0 or 1 customers come in (ok, since the bank only has one customer!), and instead of the customer signaling that they are there by sticking their card in the ATM, our system must ask if there is going to be a customer that day. For each day then, if somebody is coming – then magically via your willful suspension of disbelief, the user is now a potential bank customer. After ensuring that they are a valid customer, allow them to do as many transactions as they want to. Transactions are currently limited to deposits, withdrawal, and account inquiries. For deposits or withdrawals, ask the user for the amount – these amounts must be validated according to bank limits given below. Then at the end of the day, whether the customer came by or not, pay interest to the account. 

At the end of the simulation, display account information.

 

Sample Interaction with the user (minus user answers which are typed elsewhere):

Initializing system.

Please enter the account number to be used in this simulation

Please enter the 4 digit PIN to be used in this simulation

Please enter the beginning balance to be used in this simulation

Please enter the interest rate to be used in this simulation (NOTE 2% is written .02)

How many days in this simulation

In this dummy bank there is only 1 valid account. Work with it:

     Acct: 123456 PIN: 1234 Bal: 2000.0

Is anybody banking today?

Enter your account number

Enter your PIN

Choose:

   1) Deposit 2) Withdraw 3) Account Balance 4) Quit

Please enter the withdraw amount (between 20 and 200)

Please enter the withdraw amount (between 20 and 200)

Choose:

   1) Deposit 2) Withdraw 3) Account Balance 4) Quit

Your Account:

123456  Bal: 1850.0

Choose:

   1) Deposit 2) Withdraw 3) Account Balance 4) Quit

At end of day 1 interest paid: 0.10136986301369863

Is anybody banking today?

At end of day 2 interest paid: 0.10137541752674048

Is anybody banking today?

At end of day 3 interest paid: 0.1013809723441392

Is anybody banking today?

At end of day 4 interest paid: 0.10138652746591147

Is anybody banking today?

Enter your account number

Enter your PIN

Enter your account number

Enter your PIN

Choose:

   1) Deposit 2) Withdraw 3) Account Balance 4) Quit

Please enter the withdraw amount (between 20 and 200)

Choose:

   1) Deposit 2) Withdraw 3) Account Balance 4) Quit

Your Account:

123456  Bal: 1750.4055127803501

Choose:

   1) Deposit 2) Withdraw 3) Account Balance 4) Quit

At end of day 5 interest paid: 0.09591263083727947

Is anybody banking today?

At end of day 6 interest paid: 0.09591788632390069

Is anybody banking today?

At end of day 7 interest paid: 0.09592314209849377

Is anybody banking today?

At end of day 8 interest paid: 0.09592839816107451

Is anybody banking today?

Enter your account number

Enter your PIN

Choose:

   1) Deposit 2) Withdraw 3) Account Balance 4) Quit

Please enter the deposit amount (between 1 and 2000)

Choose:

   1) Deposit 2) Withdraw 3) Account Balance 4) Quit

Your Account:

123456  Bal: 2750.789194837771

Choose:

   1) Deposit 2) Withdraw 3) Account Balance 4) Quit

Please enter the withdraw amount (between 20 and 200)

Choose:

   1) Deposit 2) Withdraw 3) Account Balance 4) Quit

Your Account:

123456  Bal: 2650.789194837771

Choose:

   1) Deposit 2) Withdraw 3) Account Balance 4) Quit

At end of day 9 interest paid: 0.14524872300480937

Is anybody banking today?

At end of day 10 interest paid: 0.14525668183894663

Times up!

Updated account:

     Acct: 123456 PIN: 1234 Bal: 2651.0797002426148

 

Hand in:

Miscellaneous:

·         Please try to make the output of your program like mine, to aid my grading. (note that we haven’t done anything yet with specifying how many decimal places to display)

·         You will need the SavitchIn.java file (still obtainable from my WWW page  - or from previous weeks).

·         You shouldn’t have to change anything in Account.java (note that it also provides setIntRate and getIntRate methods now).

·         You can use dialog boxes if you prefer, but make sure it doesn’t get in your way.

·         Valid deposits are from $1-$2000. Valid withdrawals are from $20-$200. Valid Interest rates are greater than 0% and less than or equal to 20%. Initial balances and number of days in the simulation must be positive. Transaction choices that are invalid shouldn’t cause problems with the program. In the Sample Interaction, you can see evidence of some of this validation going on – it ALL should be done.

·         MAKE SURE YOUR PROGRAM WORKS! (i.e. more than just removing compile errors). You can test your program on the above example, but make sure you test it on other data as well - I will! Your program needs to be able to handle any valid inputs, and catch invalid values of the correct type (The SavitchIn functions catch invalid values that are the wrong type (e.g. letters where numbers are needed). 

·         Put YOUR NAME, and e-mail address in comments at the beginning of the program.

·         Remember: Indentation, meaningful variable names, and meaningful comments. Weaknesses in any of these could result in points off. You MUST include comments that explain your program in order to get full credit.