Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

For this homework you will develop four classes called Bank, Account, Customer,

ID: 3832704 • Letter: F

Question

For this homework you will develop four classes called Bank, Account, Customer, and Transaction to store account information, customer information, and transaction information of a bank. Based on the sample input data and sample run, you should identify operations of the project.

For the homework, you can use either Array or ArrayList. If you use arrays, you can assume that your Bank class can have maximum 30 Accounts, 30 Customers, and 100 Transactions. Note that an Account object can have only one Customer, and each Customer can have maximum two accounts (= one checking and one savings accounts). A Transaction object should include the account number, transaction type (= deposit, withdrawal, and closing an account), and transaction date/time information.

Sample Input File

The following file represents a sample bank data file, c:\tmp\test1.txt, which is used in the sample runs below. Note that the first line (= 4) indicates the number of customers in the bank. The customer’s information includes the name, address, zip code, and SSN. Note that each customer data is delimited by comma symbol (,).

After the customer data, there is a number of accounts (= 5 in the example). Each account information has SSN, account number, account type (1: checking, 2: savings), and current balance. Again, comma is used as a delimiter.

4

Tom Smith,123 University Center,93955,777-77-7777

Alice Smith,123 University Center,93955,888-88-8888

Joe Otter,2440 Ocean Avenue,93900,999-99-9999

Monica Smith,123 University Center,93955,123-45-7777

5

777-77-7777,1000,1,10.0

888-88-8888,2000,1,50.25

777-77-7777,3000,2,100.0

999-99-9999,5000,1,100.25

888-88-8888,6000,2,500.25

Sample Demo Program

The following presents a sample demo program called BankDemo1.java.

public class BankDemo1 {
    public static void main(String[] args)
    {
        Bank csumbBank = new Bank("My Bank");
        System.out.println("========== READ DATA ==========");
        csumbBank.readData("C:\tmp\test1.txt");
        System.out.println("========== DONE ==========");
        System.out.println(" ========== BANK INFORMATION ==========");
        csumbBank.bankInfo();
        System.out.println(" ========== ACCOUNT INFORMATION ==========");
        csumbBank.accountInfo(1000);
        csumbBank.deposit(1000, 150.25);
        System.out.println(" ========== ACCOUNT INFORMATION ==========");
        csumbBank.accountInfo(1000);
        csumbBank.withdraw(1000, 100);
        System.out.println(" ========== ACCOUNT INFORMATION ==========");
        csumbBank.accountInfo(1000);
        System.out.println(" ========== ACCOUNT CLOSE ==========");
        if (csumbBank.closeAccount(1000)) {
            System.out.println("Account closed.");
        }
        System.out.println(" ========== TRANSACTION INFO ==========");
        csumbBank.transaction(1000);
        System.out.println(" ========== TRANSACTION INFO ==========");
        csumbBank.transaction(2000);
    }

}

The following presents a sample execution result. At the sample run, we assume that the deposit of the account number 1000 happened in Sep. 28, 2015. The exact time is 15:23:25 (= HH:MM:SS format). When you run the demo program, your program should get the date and time of the deposit() method execution time. Similarly, we assume that the withdraw() and closeAccount() methods were invoked at 2015-09-28, 15:23:26 and 15:23:28, respectively.

========== READ DATA ==========

========== DONE ==========

========== BANK INFORMATION ==========

Bank Name: My Bank

Number of Customers: 4

Tom Smith: 777-77-7777

Alice Smith: 888-88-8888

Joe Otter: 999-99-9999

Monica Smith: 123-45-7777

Number of Accounts: 5

1000: $10.00

2000: $50.25

3000: $100.00

5000: $100.25

6000: $500.25

Total Balance: $760.75

========== ACCOUNT INFORMATION ==========

- Number: 1000

- Checking

- Balance: $10.00

- Customer: Tom Smith

========== ACCOUNT INFORMATION ==========

- Number: 1000

- Checking

- Balance: $160.25

- Customer: Tom Smith

========== ACCOUNT INFORMATION ==========

- Number: 1000

- Checking

- Balance: $60.25

- Customer: Tom Smith

========== ACCOUNT CLOSE ==========

Account closed.

========== TRANSACTION INFO ==========

- Account Number: 1000, Deposit ($150.25), 2015-09-28, 15:23:25

- Account Number: 1000, Withdraw ($100.00), 2015-09-28, 15:23:26

- Account Number: 1000, Account closed, 2015-09-28, 15:23:28

========== TRANSACTION INFO ==========

- No transaction for account 2000

Explanation / Answer

As an expert, I get limited time to solve this problem, so that I cannot give complete working code for this assignment but I believe I can help you by giving you useful hints which will definitely help you while writing code. Once you understood the logic behind the code then only things remained is putting thing in orderly fashion with required syntax which I believe is trivial. Always try to understand the logic behind any implementation. Writing code will be just a trivial part once you understood the process.

[Note: followings are pseudo code for this question. Student need to use standard syntax]

We need to have bank account which include 3 array list, customer, account and transaction.

Please note that we can have maximum 30 customer, 30 accounts and 100 transactions as per question.

Class Bank: Public Customer, Public account, Public transaction; //inherit customer, account and transaction classes

{

Public:

       // Create an array of objects to store the details of customer, account and transactions.

Customer Customer_detail[30];

Account Account_detail[30];

Transaction Transaction_detail[100];

Static int customer_index, account_index, transaction_index; //to count respective details

…..

….

…..

//Methods

    // Method to read data from given input file and created customer, account and transaction objects respectively.

    void readData(string path)

{

//Read line by line of test1.txt file

//1) First line indicate number of customers

Try{

//Throw errors if number of customer are greater than 30

}

Catch(exception e){ print "error"}

// Similar check boundary condition fo

// 3) Read the all the lines until end of text file reached . You may need to use for loop for that

//4) Whenever you get any customer store required details in Customer object like following.

Customer cust(" name, address, zip code, and SSN")

// Store this created customer in customer_details array;

//do it for all the customer

Customer_details[customer_index++]=cust;

// Now storing the account detail

// Create account object whenever account detail found.

// You need to loop over all the account detail present in test1.txt

Account acc( SSN, account number, account type , current balance, );

//store this account detail in acconut_detail array.

Account_detail[account_index++]=acc;

      }

Void bankinfo()

{

//Print details of customer and account ;

// loop through all the customers.

For(i=0; i<customer_index;i++)

{

// Get customer one by one

Customer temp_cust=Customer_detail[i];

// print required details of customer

print(temp_cust.getName);

Print(temp_cust.getSSN)

}

// Similary for account details;

For(i=0;i<account_index;i++)

{

Account temp_acc= Account_details[i];

//print desired details as that of required in output by using gettermethod.

Print(temp_acc.getAccount_number)

}

}

Void account_info(int account_number)

{

int found=0;

//search this account number in account_details array

For(i=0;i<account_index. i++)

{

Account temp=account_details[i];

if (temp.getAccount_number == account_number)

{

found =1;

  // we found the customer with desired account number;

   print(temp.getAccound_Number)

   print(temp.getAccound_type)

}

If(found =0 )

Print "DO NOT FOUND ACCOUND"

}

}

Void deposit(int account, into add_balance)

{

int found=0;

//search in all accounts.

For(i=0;i<account_index. i++)

{

Account temp=account_details[i];

if (temp.getAccount_number == account_number)

{

found =1;

   // we found the customer with desired account number;

// add the required deposit in account balance

   temp.setBalance(temp.getbalance + add_balance);

// whenever we do some transaction add this details to transaction objects

//create transaction object

Transaction temp_tran(account_id, "Deposit", time);

// add this transaction object in transaction_details arrayl

Transaction_details[transaction_index++] = temp_tran;

}

If(found =0 )

Print "DO NOT FOUND ACCOUND"

}

}

Void withdraw(int account, into withdraw_balance)

{

int found=0;

//search in all accounts.

For(i=0;i<account_index. i++)

{

Account temp=account_details[i];

if (temp.getAccount_number == account_number)

{

found =1;

   // we found the customer with desired account number;

// remove the required withdrawal from account balance

   temp.setBalance(temp.getbalance - withdraw_balance);

// whenever we do some transaction add this details to transaction objects

//create transaction object

Transaction temp_tran(account_id, "withdraw", time);

// add this transaction object in transaction_details arrayl

Transaction_details[transaction_index++] = temp_tran;

}

If(found =0 )

Print "DO NOT FOUND ACCOUND"

}

}

Void transaction_info(int account_id)

{

//go through all the transactions

For(i=0;i<transaction_index;i++_

{

Transcation temp=transaction_details[i];

If(temp_tran.getAccount_number == accound_id)

{

//print required details of this transaction

}

}

}

Void closeAccount(int acc_number)

{

//go through the all the accounts and delete it when found

For (i=0;i<acound_index;i++)

{

   account temp_acc=account_details[i];

If (temp_acc.get_account_number == acc_number)

{

   //delete that account

   account_details[i] = 0 ;

}

   }

}

}

Class Customer

{

Public:

// variables for customer class

// Please note you can choose these names are you wanted and also set names and limit of variables accordingly

Char name[100];

Char address[100];

Int zip_code;

Int SSN;

//Default customer

Customer()

{

name ="";

address="";

zip_code=0;

SSN=0;

}

Customer(Cust_name, Cust_address, Cust_zip_code,cust_SSN);

{

Name=Cust_name;

Address=cust_address;

Zip_code=cust_zip_code;

SSN=cust_SSN;

//Please note that above assignment may vary based on data type of variable. I.e you may need to user string copy methods to copy variable Cust_address into address.

}

//Methods:

Print_customer_details()

{

//Print Customer name, address, zip_code, and SSN

}

//Writer getter and setter method like following.

getName()

{

return name;

}

setName(cust_Name);

{

Name=cust_name;

}

//similarly write getter and setter method for other variables

}

Class Account

{

// data variables of account class

Int SSN;

Int account_number;

Int account_type;

Int current_balance;

// empty constructor

Account();

{

SSN=0;

account_number=0;

Account_type=0;

Curent_balance=0

}

//parameterized constructor

Account(custSSN, cust_account_number, cust_account_type, cust_current_balance)

{

SSN=custSSN;

account_number=cust_account_number;

account_type=cust_account_type;

Current_balance=cust_current_balance

}

//write setter and getter methods.

getSSN()

{

Return SSN;

}

SetSSN(custSSN);

{

SSN=custSSN;

}

//Similarly write for other variables

}

Class Transaction

{

Public:

Date date_time;

Char type [100]; //depost, withdrawal, closed

Int cust_number;

Transction(cust_number, type, date_time)

{

// set it to respective variables

}

//write setter and getter methods as that of customer and account class

}

Note: This exercise is very good to understand Object oriented concepts.

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote