Kanchi
ASSIGNMENT IV
(classes and String Tokenizer)

Requirements and Assumptions:

You will write a program that is similar to the ATM machine of a bank.  Customers at ``ABC Bank" will open new accounts, withdraw money,  deposit money,  make balance enquiry, and request  transaction details using the ATM machine.

The following main menu is repeated until 'q' is chosen.

o -- Open new account
t -- perform Transaction on a account
q --- quit program

When  a new account is opened, that is , when 'o' is chosen,  the coustomer provides  name, address , telephone and an initial balance to open the account.  The information  needs to be in the format  as described below.  The name must  contain only two words, the first name and the last name. For example  "Jane Doe",  "John Smith", "Bob Barr" etc.  If an invalid name is entered you must keep asking for the name until  a valid name is entered.

The address can be any string. The telephone number should be of the format "ddd-ddd-dddd" where each d is a digit.   The initial balance with which the account is opened must be a positive number. Once an account is opened, the customer gets an account number back from the program. The account number has to be different for each account. You can start the account number at 234567812345678 and increment this by one for each new account number.

Once an account is opened, a customer may choose a transaction on their account by picking 't' from the main menu.  To execute any transaction  the  customer must first enter their correct account number.  Then the customer can choose to
withdraw money , deposit money,  make a balance enquiry or request transaction details using the
following menu.

d -- Deposit amount
w -- Withdraw amount
e --Enquire balance on my account
t -- request  transaction details (of last three transactions only)
g --- Go back to main menu

If 'd' is chosen, the customer is asked for an amount to be deposited and that amount is added to the account.
If 'w 'is chosen, the customer is customer is asked for the amount that he/she wants to withdraw. If the balance
is more than that amount, then withdrawl is done successfully. If the balance is not enough the cover the withdrawl, the
account is charged $10, if the account has $10, otherwise if the account has less than $10, the account is charged whatever amount is  in the account.  If  'e' is chosen, the current balance is displayed.  If 't' is chosen the last three changes to the account is displayed (see  example below). 'g' goes back to the main menu.

Note that there is only one account in the system at a time, since we have not yet talked about arrays. Imagine
a customer opens account and does few  transactions and leaves the system. The next customer comes along and
continues the same way. In the next assignment we will will find a way to keep track of the accounts.

You must validate every input that is given. You must ensure that menu choices are validated, amount are validated
etc.

Internal Requirements:

1. I expect you to have several classes and methods. The design of the code to left to you but you must have atleast the following classes and methods.

class Account

Member Variables:
                          currentBalance (double)
                          nameOfAccountHolder (String)
                         addressOfAccoutHolder(String)
                          telephoneOfAccountHolder(String)
Member Methods:

public  Account(String name, String address, String phone, double currentBalance)
(* This is a constructor for checking account *)

<type>  depositAmount(float amount)
(Deposits amount)

<type> withdrawAmount(float amount)
(Withdraws   amount)

double getbalance();
(* returns the balance in the current account *)

void setBalance(float amt)
(* sets the balance to a specified amount *)

[And all other set and get methods]

void printTrasactionDetails(....)
(prints details of last 3 transactions and name, address and telelphone number of the account holder)

} //end class

2. You may add other methods and variables to the "Account" class defined above, but you cannot delete
any.

3. You may have other classes and methods. For example you may choose to have a class that prints all
the menus and reads choices, you may have a class that reads and validates account holder information.
Infact, it is suggested that you have very few methods in the MainClass and only a few lines in the main()
method and do most of the tasks in other classes and methods.

4. Use constants where appropritate and validate ALL user inputs.

5. Use StringTokenizer to parse the name. Do not read first name and last name seperatelely.
 

Sample Session:

I am Saroja Kanchi. Welcome to my ATM. Please choose from the following menu.
 

o -- Open new account
t -- perform Transaction on a account
q --- quit program

Your Choice:t
Oops... you must open account first :)

o -- Open new account
t -- perform Transaction on a account
q --- quit program

Your Choice:o

Okay.. I will open an account for you. Please provide the following information in the format
requested.

Your Name (first last) : Saroja Kanchi
Your Address: 1700 West Third Ave, Flint MI 88888
Your Telephone(ddd-ddd-dddd): 334-333-lk34
*****INVALID  TRY AGAIN****
Your Telephone(ddd-ddd-dddd):333-333-4533
Staring Balance: $100

Congratulations.. You are now a customer  at ABC Bank.. where your money rocks.... Your account number is
234567812345678.  Keep this in a safe place.
 

o -- Open new account
t -- perform Transaction on a account
q --- quit program

Your Choice:t.

Welcome to Trasactions... You must provide your account number so that I can perform the transactions.

Your Account Number: 234567812345690

Oops .. Please provide your correct account number.. If you don't know your account number call
1-800-ABC-HELP
Your Account Number: 234567812345678

Your account number is validated..

d -- Deposit amount
w -- Withdraw amount
e --Enquire balance on my account
t -- request last 5 transaction details.
g --- Go back to main menu

Your Choice:w

Enter Amount To Withdraw: $30

Withdrawl successful.. Your new balance is $70

d -- Deposit amount
w -- Withdraw amount
e --Enquire balance on my account
t -- request last 5 transaction details.
g --- Go back to main menu

Your Choice:d

Enter Amount to Deposit :$50

Deposit Successful.. Your New Balance is $120
d -- Deposit amount
w -- Withdraw amount
e --Enquire balance on my account
t -- request last 5 transaction details.
g --- Go back to main menu

Your Choice:w

Enter Amount to Withdraw: $140

Sorry.. Your balance is not suffient.. I am charging your account $10. Your new balance is $110
d -- Deposit amount
w -- Withdraw amount
e --Enquire balance on my account
t -- request last 5 transaction details.
g --- Go back to main menu

Your Choice:e

Your balance is $110
d -- Deposit amount
w -- Withdraw amount
e --Enquire balance on my account
t -- request last 5 transaction details.
g --- Go back to main menu

Your Choice:t

 **************************** ABC TRANSACTION DETAILS *****************
Name: Saroja Kanchi
Address: 1700 West Third Ave, Flint MI 88888
Telephone: 333-333-4533

The last  (upto three) changes to your balance occured in the transactions below. It is printed in
reverse order.

Old Balance  $120       Service Charge for Insufficient Amount : $10        New Balance $110

Old Balance $70          Deposit:$50                                                                        New Balance: $120

Old Balance $100        WithDrawl: $ 30                                                                 New Balance: $70
d -- Deposit amount
w -- Withdraw amount
e --Enquire balance on my account
t -- request last 5 transaction details.
g --- Go back to main menu

Your Choice:d

Enter Amount to Deposit:$300

Deposit sucessful.. Your new balance is $410
d -- Deposit amount
w -- Withdraw amount
e --Enquire balance on my account
t -- request last 5 transaction details.
g --- Go back to main menu

Your Choice:t

**************************** ABC TRANSACTION DETAILS *****************
Name: Saroja Kanchi
Address: 1700 West Third Ave, Flint MI 88888,
Telephone: 333-333-4533

The last  (upto three) changes to your balance occured in the transactions below. It is printed in
reverse order.

Old Balance $110      Deposit: $300                                                                     New Balance $410

Old Balance  $120       Service Charge for Insufficient Amount : $10        New Balance $110

Old  Balance $70          Deposit:$50                                                                        New Balance: $120
d -- Deposit amount
w -- Withdraw amount
e --Enquire balance on my account
t -- request last 5 transaction details.
g --- Go back to main menu

Your Choice:g
 
 

o -- Open new account
t -- perform Transaction on a account
q --- quit program

Your Choice:q

Quitting program.............We thank you for your business at ABC Bank.... where your money rocks.... Bye.
 
 
 

                                              FOLLOW ALL STYLE GUIDE LINES AND SUBMISSION INSTRUCTIONS.

 
 
    Assignments and Labs Page  CPSC101 Homepage  Saroja Kanchi's Homepage