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

Hello everybody some help is appreciated thanks. Have attached a picture of the

ID: 3740430 • Letter: H

Question

Hello everybody some help is appreciated thanks. Have attached a picture of the output and requirements for the java code.

In a different Java class, called TheBank.java create a Bank program with the following specifications:

? The Bank’s client file information is loaded from a file (named AccountBackUp.dat) that contains at most 1000 lines. Each line of the file contains a string representing the customer name, a unique integer identification number for the account and the current account balance in the account. (An array of BankAccounts should be created to hold the client file information. Use a constructor from the BankAccount class to instantiate each of the accounts.)

? Next, the Bank’s monthly transaction file (named TransactionsJanuary.dat) containing a month of transaction information is loaded from a file. (There is no limit on the number of lines in the file.) Each line contains a customer name and unique identification number, the type of transaction and the amount of the transaction. The transaction type could be one of (deposit, withdrawal, interest, charge). The amount of a deposit must be added to the BankAccount’s balance; the amount of a withdrawal or (service) charge must be subtracted from the balance; and interest requires adding ‘amount’ % interest to the BankAccount. Before applying each transaction, the name and identification number must be checked to see that they correspond to a single account; an error log must be added to an error log file (called error.dat) if they do not. Use member methods of the BankAccount class to alter the attributes of the appropriate BankAccount object.

? Output the entire updated Bank client file information (including customer name, identification number and account balance) into a file, ensuring that it is sorted in order of ascending identification number. Observe that the instance method toString() can be used to make a single String containing all attributes of a BankAccount object.

? Output, to the screen, the Bank client file information (just the customer name and account balance) to the screen, ensuring that it is sorted in order of descending account balance amount. This output should be output in groups of 20 lines, then the output stops waits for the user to hit the ‘Enter’ key. HAND IN: Submit your TheBank.java file using the ‘Assignments’ link of

Sample output using the provided AccountBackUp.dat and TransactionsJanuary.dat files: TRAN SA CTION UP DA T ING 32145 Jones, John 4389.57 45325 Jefferson, Jennifer 879.54 56324 Anderson, Blade 3424.34 34524 Babbled, Jay 163423.4 34668 Bonwild, Wendy 3416.5 32684 Cerute, Brent 23467.4 21356 Day, Darren 3124.65 ERROR: Account/name mismatch: Woods, Jim 34668 CLIENT A CCOUNT S 45325 Jefferson, Jennifer 704.46 34668 Bonwild, Wendy 3466.06 32145 Jones, John 4582.419999999998 56324 Anderson, Blade 14019.753255610402 32684 Cerute, Brent 23206.560000000005 21356 Day, Darren 26781.60651353751 34524 Babbled, Jay 161789.97999999998

Explanation / Answer

I have written code based on the requirement but the trasaction file doesnot have transaction type data also data for interest is not mention here is it a percent or simply integer value. By considering type of interest value as integer I have implemented here, also I am considering here the value for transaction type will be mention in your data file. Also here for testing purpose you can create one class with main method and call first loadAccountDetails() details method then call transactionDetails(). you will have to give path of file for account details and transaction details.

1# Bank.java

import java.io.BufferedReader;

import java.io.FileReader;

import java.io.IOException;

import java.util.ArrayList;

import java.util.HashMap;

import java.util.Map;

public class Bank {

ArrayList<BankAccount> bankAccountList=new ArrayList<BankAccount>();

Map<Integer, ArrayList<BankAccount>> bankMapData=new HashMap<>();

public void loadAccountDetails() throws IOException{

String accountBackup="Path of file\AccountBackup.txt";

BufferedReader br =new BufferedReader(new FileReader(accountBackup));

String st;

while((st=br.readLine())!=null){

String[] strArray=st.split(" ");

BankAccount ba=new BankAccount(strArray[1],Integer.parseInt(strArray[0]) , Double.parseDouble(strArray[2]));

bankAccountList.add(ba);

bankMapData.put(Integer.parseInt(strArray[0]), bankAccountList);

}

}

public void transactionDetails() throws IOException{

String transactionData="Path of FIle\TransactionJanuary.txt";

BufferedReader br = new BufferedReader(new FileReader(transactionData));

String st;

while((st=br.readLine())!=null){

String[] transactionArray=st.split(" ");

if(transactionArray[3].equalsIgnoreCase("deposit")){

if(verifyAccount(Integer.parseInt(transactionArray[0]), transactionArray[1])){

for(int i=0;i<bankAccountList.size();i++){

if(Integer.parseInt(transactionArray[0])==bankAccountList.get(i).getCustomerId()){

bankAccountList.get(i).setAccountBalance(bankAccountList.get(i).getAccountBalance()+Double.parseDouble(transactionArray[2]));

}

}

}else

System.out.println("Account Number and User name didnot match with database");

}

else if(transactionArray[3].equalsIgnoreCase("withdraw")){

if(verifyAccount(Integer.parseInt(transactionArray[0]), transactionArray[1])){

for(int i=0;i<bankAccountList.size();i++){

if(Integer.parseInt(transactionArray[0])==bankAccountList.get(i).getCustomerId()){

bankAccountList.get(i).setAccountBalance(bankAccountList.get(i).getAccountBalance()-Double.parseDouble(transactionArray[2]));

}

}

}else{

System.out.println("Account Number and User name didnot match with database");

}

}

else if(transactionArray[3].equalsIgnoreCase("interest")){

if(verifyAccount(Integer.parseInt(transactionArray[0]), transactionArray[1])){

for(int i=0;i<bankAccountList.size();i++){

if(Integer.parseInt(transactionArray[0])==bankAccountList.get(i).getCustomerId()){

bankAccountList.get(i).setAccountBalance(bankAccountList.get(i).getAccountBalance()+Double.parseDouble(transactionArray[2]));

}

}

}else{

System.out.println("Account Number and User name didnot match with database");

}

}

}

}

public boolean verifyAccount(int accountId,String accountUserName){

boolean flag=false;

ArrayList<BankAccount> bankAccountDetails=bankMapData.get(accountId);

if(!bankAccountDetails.isEmpty()){

for(int i=0;i<bankAccountDetails.size();i++){

if(accountId==bankAccountDetails.get(i).getCustomerId() && accountUserName.equalsIgnoreCase(bankAccountDetails.get(i).getCustomerName())){

flag = true;

}

}

}

return flag;

}

#2. BankAccount.java

public class BankAccount {

private String customerName;

private int customerId;

private double accountBalance;

public BankAccount(String customerName,int customerId,double accountBalance) {

this.customerName=customerName;

this.customerId=customerId;

this.accountBalance=accountBalance;

}

public String getCustomerName() {

return customerName;

}

public void setCustomerName(String customerName) {

this.customerName = customerName;

}

public int getCustomerId() {

return customerId;

}

public void setCustomerId(int customerId) {

this.customerId = customerId;

}

public double getAccountBalance() {

return accountBalance;

}

public void setAccountBalance(double accountBalance) {

this.accountBalance = accountBalance;

}

}

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