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

Working with java eclipse IDE for Object Oriented and GUI Programming. The objec

ID: 3814656 • Letter: W

Question

Working with java eclipse IDE for Object Oriented and GUI Programming.
The objectives of this assignment are to:
- Gain an understanding of inheritance. - Gain further understanding of input and output of text files. - Develop and test a small Java program which is composed of several classes that apply the concepts of objectives 1 and 2.

Assignment
A bank provides two types of accounts; checking account and savings account. Both types of accounts have an account number and a balance. Both accounts support deposits and withdrawals. However, for a savings account, a withdrawal can never exceed the balance. An attempt to withdraw an amount that exceeds the balance of a savings account will withdraw just the balance. On the other hand, a checking account can go into overdraft state. During the course of a month, many transactions (e.g. deposits and withdrawals) can be performed against an account. These are recorded and the balance of the account is updated. All transactions record a description; “Deposit” for deposits, “Withdrawal” for withdrawals against savings accounts, and “Check” for withdrawals against checking accounts. At the end of the month checking accounts incur a 10 cent per check fee which is recorded as a single transaction with a description “Check fee” which is recorded at the end of the month. In addition, a checking account incurs a $25 overdraft fee for each withdrawal which results in a balance less than zero. Each overdraft fees will be recorded as a transaction with description “Overdraft fees”. Savings accounts receive a 0.5% interest. Interest, if applicable, is recorded as a transaction with description “Interest”. After accounting for end of month processing, statements are printed.
*** Your task is to write a program to: i) post a set of transactions to set of accounts, ii) perform end of month processing applying interest and check fees, iii) print statements, and iv) save the updated accounts to a new file.
Input:
Account.txt file - a comma separated text file containing the fields:
Account type - either ‘C’ or ‘S’ for checking or savings Account number - 8 digits Account balance - up to 8 numeric digits with 2 decimals
Trans.txt file - a comma separated text file containing the fields:

Account number - 8 digits Date - in the format of “MM/dd/yyyy” Transaction type - either ‘D’ or ‘W’ for deposit or withdrawal. Amount - up to 8 numeric digits with 2 decimals
Output:
1) Printed statements according to the following sample:
Account: 34385543 Type: Checking Balance: $ 602.00
Date Transaction Amount Balance 9/02/2009 Deposit $ 500.00 $ 1000.00 9/05/2009 Check $ 1200.00 $ -200.00 9/07/2009 Deposit $ 500.00 $ 300.00 9/15/2009 Check $ 400.00 $ -100.00 9/25/2009 Deposit $ 500.00 $ 400.00 9/30/2009 Check fees $ .20 $ 299.90 9/30/2009 Overdraft fees $ 50.00 $ 349.90
Account: 34385577 Type: Savings Balance: $ 2241.15
Date Transaction Amount Balance 9/12/2009 Deposit $ 1000.00 $ 2230.00 9/30/2009 Interest $ 11.15 $ 2241.15
2) ResultAccounts.txt same format at Account.txt


Implementation requirements:
- You must use inheritance for the accounts. Do not have any test for account type of account except during input of the account file. Input processing simply creates different types of account according to the account type field. (Hint: provide an abstract method for end of month processing).

- You do not need to use inheritance for the transaction record. A transaction record need only have attributes date, description, amount, and balance.

- ABIDE by good programming practices. Define javadoc, good formatting, naming conventions, etc.


Accounts.txt C,73829123,1030.50 S,73829999,3000.89 C,73849222,530.21 S,73843923,1203.23 C,73832911,1.35 C,73812930,-24.00 S,73843942,123.12 S,74892312,1250.50 C,73829123,1030.50 S,73829999,3000.89 C,73849222,530.21 S,73843923,1203.23 C,73832911,1.35 C,73812930,-24.00 S,73843942,123.12 S,74892312,1250.50

Trans.txt 73829123,10/12/2009,W,500.00 73849222,10/12/2009,W,530.00 73843942,10/12/2009,D,1000.00 73829123,10/13/2009,W,300.00 73829123,10/14/2009,D,1287.78 73829123,10/15/2009,W,500.00 73849222,10/15/2009,D,1000.00 73849222,10/16/2009,W,350.00 73849222,10/16/2009,W,128.00 73829999,10/16/2009,D,500.00 73849222,10/17/2009,W,481.00 73849222,10/17/2009,W,1.37 73843942,10/17/2009,D,1000.00 73843923,10/18/2009,W,203.23 73843923,10/18/2009,D,1000.00 73832911,10/18/2009,W,5.00 73832911,10/19/2009,D,50.00 73832911,10/20/2009,W,36.95 73832911,10/21/2009,W,15.43 73832911,10/22/2009,D,78.54 73812930,10/24/2009,D,12674.89 73843942,10/24/2009,D,1000.00 73812930,10/25/2009,W,11675.09 73812930,10/26/2009,D,2400.00 73829123,10/12/2009,W,500.00 73849222,10/12/2009,W,530.00 73843942,10/12/2009,D,1000.00 73829123,10/13/2009,W,300.00 73829123,10/14/2009,D,1287.78 73829123,10/15/2009,W,500.00 73849222,10/15/2009,D,1000.00 73849222,10/16/2009,W,350.00 73849222,10/16/2009,W,128.00 73829999,10/16/2009,D,500.00 73849222,10/17/2009,W,481.00 73849222,10/17/2009,W,1.37 73843942,10/17/2009,D,1000.00 73843923,10/18/2009,W,203.23 73843923,10/18/2009,D,1000.00 73832911,10/18/2009,W,5.00 73832911,10/19/2009,D,50.00 73832911,10/20/2009,W,36.95 73832911,10/21/2009,W,15.43 73832911,10/22/2009,D,78.54 73812930,10/24/2009,D,12674.89 73843942,10/24/2009,D,1000.00 73812930,10/25/2009,W,11675.09 73812930,10/26/2009,D,2400.00 C, 73829123,1030.50 S, 73829999, 3000.89 C, 73849222,530.21 S, 73843923, 1203.23 C, 738329 11, 1.35 C, 73812930, -24.00 S, 73843942,123.12 S, 74892312, 1250.50

Explanation / Answer

import java.io.*;
import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;

abstract class BankAccount{

   String accNo;
   String accType;
   double balance;
   int noTrans;
   double withdraw;
   double deposit;
   Transaction[] tran = new Transaction[noTrans];
  
   public BankAccount(String accType,String accNo, double balance) {
       super();
       this.accNo = accNo;
       this.balance = balance;
       this.accType = accType;
   }
  
   public String getaccNo() {
       return accNo;
   }

public Transaction getTransaction(int index){
       return tran[index];
   }
  
   public String getAccType() {
       return accType;
   }
public double getBalance() {
       return balance;
   }

public abstract double getDeposit();
  
public abstract double getWithdraw();
  
}

class CheckingAccount extends BankAccount{
  
   double overDraft;
   double overDraftFee = 25.00;
   double checkFee = .10;
  
   public CheckingAccount(String accNo,String accType, double balance) {
       super(accNo, accType, balance);
      
   }
   Transaction tran[] = new Transaction[noTrans];
   public double getDeposit(){
   }
  
   public double getOverDraft() {
       return overDraft;
   }

   @Override
   public double getDeposit() {
      
       return deposit;
   }

   @Override
   public double getWithdraw() {
      
       return withdraw;
   }
  
}

class SavingAccount extends BankAccount{

   double interest = .005;

   public SavingAccount(String accNo,String accType, double balance) {
       super(accNo,accType, balance);
      
   }

   @Override
   public int getDeposit() {
       // TODO Auto-generated method stub
       return 0;
   }

   @Override
   public int getWithdraw() {
       // TODO Auto-generated method stub
       return 0;
   }
  
}

class Transaction {

   private String accountNum;
   private String date;
   private String tranType;
   private double amount;
  
  
   public Transaction(String accountNum, String date, String tranType,
           double amount) {
       super();
       this.accountNum = accountNum;
       this.date = date;
       this.tranType = tranType;
       this.amount = amount;
   }

   /**
   * @return the accountNum
   */
   public String getAccountNum() {
       return accountNum;
   }

   /**
   * @return the date
   */
   public String getDate() {
       return date;
   }

   /**
   * @return the tranType
   */
   public String getTranType() {
       return tranType;
   }

   /**
   * @return the amount
   */
   public double getAmount() {
       return amount;
   }
  
  
}

class ReadTransFromText {

   private BufferedReader in;
   public ReadTransFromText(String fileName) throws FileNotFoundException{
       in = new BufferedReader(new FileReader(fileName));
   }
  
   ArrayList<Transaction> listTrans=new ArrayList<Transaction>();
   public List<Transaction> readTran(String acc) throws IOException{
       String line = in.readLine();
       while(line!=null)
       {
       String[] fields = line.split(",");


       String accNo = fields[0];
       String date = fields[1];
       String tranType = fields[2];
       String sAmount = fields[3];
       double amount = Double.parseDouble(sAmount);
       if(accNo.equals(acc)
       {
           Transaction tran = new Transaction(accNo,date,tranType,amount);
           listTrans.add(trans);
       }
       }
      
   }
}

class ReadAccountFromText {

   private BufferedReader in;
   public ReadAccountFromText(String fileName) throws FileNotFoundException{
       in = new BufferedReader(new FileReader(fileName));
   }
   public BankAccount readAcc() throws IOException{
       String line = in.readLine();
       if(line == null){
           return null;
       }
       /**
       * delimiter
       */
       String[] fields = line.split(",");


       String accType = fields[0];
       if(accType.equals("C")){
       String accNo = fields[1];
       String sBalance = fields[2];
       double balance = Double.parseDouble(sBalance);
       CheckingAccount cAccount = new CheckingAccount(accType, accNo, balance);
       return cAccount;
       }else if(accType.equals("S")){
           String accNo = fields[1];
           String sBalance = fields[2];
           double balance = Double.parseDouble(sBalance);
           SavingAccount sAccount = new SavingAccount(accType, accNo, balance);
           return sAccount;
      
      
}
      
      
   }
}

public class BankAccDriverClass
{

public static void main(String args[])
{

//Read Accounts.txt File
ReadAccountFromText read=new ReadAccountFromText();
BankAccount getAcc=read.readAcc();


//this we are doing for only one A/C number, you can loop in the file to do it for all the a/c numbers given in the file:
//For this Acc Number, read the transactions:
ReadTransFromText readTrans=new ReadTransFromText();

ArrayList<Transaction> listTrans=readTrans.readTran(getAcc.getaccNo());

//Now we have all the transactions for a particular Acc No. We can prepare the sample Result File

double balance=getAcc.getBalance();
String accType=getAcc.getAccType();
double newBal=0;

for(int i=0;i<listTrans.length;i++)
{
       Transaction tr=(Transaction)listTrans.get(i);
       String tranType = tr.getTranType();
       double amount = tr.getAmount();
      
       if(accType.equals("s") && tranType.equals("w"))
       {
           if(amount>balance)
           balance=0;
       }
      
       else if (tranType.equals("d"))
       {
           balance=balance+amount;
       }

       //Printing Result after Each Transaction
      
       String result=(tr.getDate() + " " + tranType+ " "+ amount+" "+balance;
       System.out.println(result);
       //Write this result to a File

}

}

}

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