Question
You have been hired as a programmer by a major bank. Your first project is a small banking transaction system. Each account consists of a
You have been hired as a programmer by a major bank. Your first project is a small banking transaction system. Each account consists of a number and a balance. The user of the program (the teller) can create a new account, as well as perform deposits, withdrawals, balance inquiries, close accounts, etc.
For this assignment, you must use Classes and move functionality into the classes. Specifically, you should have at least the following classes:
1. A Bank class which consists of an array of Accounts and the number of accounts currently active in the bank.
2. An Account class which consists of a Depositor, an account number, an account type, and a balance.
3. A Depositor class which has a Name and a social security number
4. A Name class which consists of first and last names.
5. A DateInfo class which consists of year, month, and dayOfMonth data members.
You must add appropriate methods to each class so as to implement the functionality of each of the following methods:
Initially, the account information of existing customers is to be read into an array of BankAccount objects. The private data members of the BankAccount Class will include: first name, last name, social security number, account number, account type (Checking, Savings, or CD), and account balance. The bank can handle up to MAX_NUM accounts. Use the following function to read in the data values:
public static int readAccts(BankAccount[] account, int maxAccts);
This method fills up the array (up to maxAccts) and returns the actual number of accounts read in (referred to as numAccts). After initialization, print the initial database of accounts.
Use method printAccts() described below. The program then allows the user to select from the following menu of transactions: Select one of the following:
W - Withdrawal
D - Deposit
N - New account
B - Balance
I - Account Info
X - Delete Account
Q - Quit
Use the following method to produce the menu:
public static void menu()
This method only displays the menu. The main program then prompts the user for a selection. You should verify that the user has typed in a valid selection (otherwise print out an error message and repeat the prompt).
Once the user has entered a selection, one of the following methods should be called to perform the specific transaction. At the end, before the user quits, the program prints the contents of the database.
public static int findAcct(BankAccount[] account, int numAccts, int reqAccount);
This method returns the index of reqAccount in the BankAccount array if the account exists, and -1 if it doesn't. It is called by all the remaining methods.
public static void withdrawal(BankAccount[] account, int num_accts);
This method prompts the user for the account number. If the account does not exist, it prints an error message. Otherwise, it asks the user for the amount of the withdrawal. If the account does not contain sufficient funds, it prints an error message and does not perform the transaction.
public static void deposit(BankAccount[] account, int num_accts);
This method prompts the user for the account number. If the account does not exist, it prints an error message. Otherwise, it asks the user for the amount of the deposit.
public static int newAcct(BankAccount[] account, int num_accts);
This method prompts the user for a new account number. If the account already exists, it prints an error message. Otherwise, it adds the account to the database. The method then prompts the user to enter the new depositors first name, last name, social security number, the account type (Checking, Savings, or CD), and the initial opening deposit.. The method returns the new number of accounts in the database.
public static int deleteAcct(BankAccount[] account, int num_accts);
This method prompts the user for an account number. If the account does not exist, or if the account exists but has a non-zero balance, it prints an error message. Otherwise, it closes and deletes the account. It returns the new number of accounts.
public static void balance(BankAccount[] account, int num_accts);
This method prompts the user for an account number. If the account does not exist, it prints an error message. Otherwise, it prints the account balance.
public static void accountInfo(BankAccount[] account, int num_accts);
This method prompts the user for a social security number (SSN). If no account exists for this SSN, it prints an error message. Otherwise, it prints the complete account information for all of the accounts with this SSN
public static void printAccts(BankAccount[] account, int num_accts);
This method prints a table of the complete account information for every active account.
Each of the methods should be re-implemented utilizing a class method. (You will have to decide as to which class each method belongs.) In addition, each class should minimally have a default constructor and possibly additional parametized constructors
The data members of each class must be private. As such, you may need to provide accessor and mutator methods.
Remember, all I/O should be done only in the methods of the class that contains the main() method
initially, the account information of existing customers is to be read into the database. The bank can handle a maximum of MAX_NUM accounts. The program keeps tracks of the actual number of currently active accounts. A table of the initial database of active accounts should be printed.
Note 1: The Clear Check transaction is only valid for checking accounts. It is like a withdrawal; except, you must also check the date of the check. You may only clear a check if the date on the check is no more than six months ago. No post-dated checks (checks with a future date) may be cleared. Use the DataeInfo class to implement this. In addition, a check will clear only if there is sufficient funds in the account. If the account lacks sufficient funds, the check will not clear and the account will be charged a $2.50 Service Fee for bouncing a check.
Note 2: CD accounts will now contain a Maturity Date. Deposits and Withdrawals will be allowed only on or after the maturity date. When a deposit or withdrawal is made, have the user select a new maturity date fro the CD. the choices are either 6, 12, 18, or 24 months from the date of the deposit or withdrawal. Again, use the DateInfo class to implement this.
Note 3. Use the Calendar class to assist you in implementing the DateInfo class.
Once the user has entered a selection, appropriate methods (in the class that contains the main() method) should be called to perform the specific transaction. These methods will call the class implemented methods as necessary. At the end, before the user quits, the program prints the contents of the final database.
Minimal Requirements:
1a. The Bank class should at least have a default constructor that would allow statements of the form:
Bank bank = new Bank();
1b. The Bank class should have at least have the following methods:
public int openNewAcct(...) (return value indicates success or reason for failure) public int deleteAcct(...) (return value indicates success or reason for failure) public int findAcct(...) (return value indicates index of found Account or reason for failure) public Account getAcct(...) public void setAcct(...)
2a. The Account class should at least have a constructor that would allow statements of the form: Account myAccount = new Account(...); //or account[i] = new Account()
2b. The Account class should have at least the following methods: public double getBalance(...) public int makeDeposit(...) (return value indicates success or reason for failure) public int makeWithdrawal(...) (return value indicates success or reason for failure) public int clearCheck(...) (return value indicates success or reason for failure) public Depositor getDepositor(...) public int getAcctNumber(...) public String getAcctType(...) public void setDepositor(...) public void setAcctNumber(...) public void setAcctType(...)
3a. The Depositor class should at least have a constructor that would allow statements of the form: Depositor depositor = new Depositor(...);
3b. The Depositor class should at least the following methods: public Name getName(...) public String getSSN(...) public void setName(...) public void setSSN(...)
4a. The Name class should at least have a constructor that would allow statements of the form: Name name = new Name(...);
4b. The Name class should at least the following methods: public String getFirstName(...) public String getLastName(...) public void setFirstName(...) public void setLastName(...)
5a. The DateInfo class should at least have a constructor that would allow statements of the form: DateInfo date = new DateInfo(...);
5b. The DateInfo class should at least the following methods: public int compareDate(...) //used to compare two DateInfo objects - returns signal to indicate result of comparison public int getYear(...) public int getMonth(...) public int getDayOfMonth(...) public void setYear(...) public void setMonth(...) public void setDayOfMonth(...)
6. Add additional constructors and methods to each class as necessary.
7. The class containing the main() method should have at least the following methods: public static void main(String[] args) public static int readAccts(...) public static void printAccts(...); public static void menu(...) public static void balance(...); public static void deposit(...); public static void withdrawal(...); public static void clearCheck(...); public static void acctInfo(...); public static void newAcct(...); public static void deleteAcct(...);
8. All I/O should be done only in the methods of the class that contains the main() method.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started