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

Problem: Checking Account +-----------------------+ This project involves a simp

ID: 3640846 • Letter: P

Question

Problem: Checking Account
+-----------------------+

This project involves a simple checking account problem that requires the
following specific tasks.

1. Customer deposits
2. Customer withdraw
3. Applying service fee
4. Getting current balance
5. ... Add other functionality as needed

A check account fields consists of these

1. First Name, Last Name
2. Account Number
3. Balance, which reflects the current amount at the account
4. Amount
5. Transaction, which could be deposit, withdraw, or charge
6. Date
7. ...

Requirements
+------------------------+
1. Use plain file as database to maintain the customer data. Each transaction
must be recorded into this file.

2. Print current balance after each five transaction.

3. Reading directly from input stream into Java data type is error prone.
For instance, if the data consists of a set of digits mixed with alphabet
while it was expected to be a pure number, the reading operation most
certainly will fail. One possible solution to this problem is writing a
filter which helps verify that the incoming data is the correct data type.
So, add filtering feature for your program.
4. You must use method for each task outlined above.

2. Use the data file provided to test your program. The exact copy of the
data is given below.

Id Date First Name Last Name Transaction Amount
----------------------------------------------------------------------
1024 01/01/2007 Charles Babbage deposit 32.00
1024 01/03/2007 Charles Babbage deposit 96.00
1024 01/10/2007 Charles Babbage deposit 16.00
1024 01/13/2007 Charles Babbage withdraw 96.00

1024 01/31/2007 Charles Babbage withdraw 32.00
1024 02/03/2007 Charles Babbage deposit 32.00
1024 02/07/2007 Charles Babbage deposit 96.00
1024 02/11/2007 Charles Babbage deposit 16.00
1024 02/17/2007 Charles Babbage withdraw 32.00

1024 03/01/2007 Charles Babbage deposit 32.00
1024 03/02/2007 Charles Babbage deposit 32.00
1024 03/04/2007 Charles Babbage deposit 32.00
1024 03/08/2007 Charles Babbage withdraw 32.00
1024 03/16/2007 Charles Babbage withdraw 32.00

Explanation / Answer

If you rate me good. I will complete the file reading part..


public class CheckingAccount {

    private int id;
    private String fname;
    private String lname;
    private double balance=0;
    private java.util.ArrayList<Transaction> transactionList;

    CheckingAccount(int id, String fname, String lname) {
        this.id = id;
        this.fname = fname;
        this.lname = lname;
        transactionList = new java.util.ArrayList<Transaction>();
    }

    class Transaction {
        String date;
        String type;
        double amount;

        Transaction(String date, String type, double amount) {
            this.date = date;
            this.type = type;
            this.amount = amount;
        }
    }

    void addTransaction(String date, String type, double amount) {
        if (type.equals("deposit")) {
            deposit(amount);
        }else if (type.equals("withdraw")) {
            withdraw(amount);
        }        
        transactionList.add(new Transaction(date, type, amount));
    }

    void deposit(double amount) {
        this.balance = this.balance + amount;
    }

    void withdraw(double amount) {
        this.balance = this.balance - amount;
    }

    void serviceFee() {
        //Doesnt specify how much service Fee to apply.
        this.balance = this.balance-0.50;
    }

    double getBalance() {
        return this.balance;
    }

    void loadFile(String fileName) {
        
    }
    void printHistory() {

        System.out.println();
        System.out.println("Account ID      : " + this.id);
        System.out.println("Account Name    : " + this.fname + " " + this.lname);
        System.out.println("-------------------------------------------------");
        for (int i = 0; i < transactionList.size(); i++) {
            Transaction history = (Transaction) transactionList.get(i);
            if(history.type.equals("withdraw"))
            System.out.println(" -$" + history.amount + " | " + history.date + " | " + history.type);
            else
            System.out.println("   $" + history.amount + " | " + history.date + " | " + history.type);
        }
        System.out.println("-------------------------------------------------");
        System.out.println("Total Balance   : $"+this.balance);

    }

    public static void main(String[] args) {
        CheckingAccount account = new CheckingAccount(1024, "Charles", "Babbage");
        account.addTransaction("01/01/2007", "deposit", 32);
        account.addTransaction("01/01/2007", "deposit", 96);
        account.addTransaction("01/01/2007", "deposit", 16);
        account.addTransaction("01/01/2007", "withdraw", 96);
        account.addTransaction("01/01/2007", "withdraw", 32);
        account.addTransaction("01/01/2007", "deposit", 96);
        account.addTransaction("01/01/2007", "deposit", 16);
        account.addTransaction("01/01/2007", "withdraw", 32);
        account.addTransaction("01/01/2007", "deposit", 32);
        account.addTransaction("01/01/2007", "deposit", 32);
        account.addTransaction("01/01/2007", "deposit", 32);
        account.addTransaction("01/01/2007", "withdraw", 32);
        account.addTransaction("01/01/2007", "withdraw", 32);
        
        account.printHistory();
    }
}

If you rate me good. I will complete the file reading part..


public class CheckingAccount {

    private int id;
    private String fname;
    private String lname;
    private double balance=0;
    private java.util.ArrayList<Transaction> transactionList;

    CheckingAccount(int id, String fname, String lname) {
        this.id = id;
        this.fname = fname;
        this.lname = lname;
        transactionList = new java.util.ArrayList<Transaction>();
    }

    class Transaction {
        String date;
        String type;
        double amount;

        Transaction(String date, String type, double amount) {
            this.date = date;
            this.type = type;
            this.amount = amount;
        }
    }

    void addTransaction(String date, String type, double amount) {
        if (type.equals("deposit")) {
            deposit(amount);
        }else if (type.equals("withdraw")) {
            withdraw(amount);
        }        
        transactionList.add(new Transaction(date, type, amount));
    }

    void deposit(double amount) {
        this.balance = this.balance + amount;
    }

    void withdraw(double amount) {
        this.balance = this.balance - amount;
    }

    void serviceFee() {
        //Doesnt specify how much service Fee to apply.
        this.balance = this.balance-0.50;
    }

    double getBalance() {
        return this.balance;
    }

    void loadFile(String fileName) {
        
    }
    void printHistory() {

        System.out.println();
        System.out.println("Account ID      : " + this.id);
        System.out.println("Account Name    : " + this.fname + " " + this.lname);
        System.out.println("-------------------------------------------------");
        for (int i = 0; i < transactionList.size(); i++) {
            Transaction history = (Transaction) transactionList.get(i);
            if(history.type.equals("withdraw"))
            System.out.println(" -$" + history.amount + " | " + history.date + " | " + history.type);
            else
            System.out.println("   $" + history.amount + " | " + history.date + " | " + history.type);
        }
        System.out.println("-------------------------------------------------");
        System.out.println("Total Balance   : $"+this.balance);

    }

    public static void main(String[] args) {
        CheckingAccount account = new CheckingAccount(1024, "Charles", "Babbage");
        account.addTransaction("01/01/2007", "deposit", 32);
        account.addTransaction("01/01/2007", "deposit", 96);
        account.addTransaction("01/01/2007", "deposit", 16);
        account.addTransaction("01/01/2007", "withdraw", 96);
        account.addTransaction("01/01/2007", "withdraw", 32);
        account.addTransaction("01/01/2007", "deposit", 96);
        account.addTransaction("01/01/2007", "deposit", 16);
        account.addTransaction("01/01/2007", "withdraw", 32);
        account.addTransaction("01/01/2007", "deposit", 32);
        account.addTransaction("01/01/2007", "deposit", 32);
        account.addTransaction("01/01/2007", "deposit", 32);
        account.addTransaction("01/01/2007", "withdraw", 32);
        account.addTransaction("01/01/2007", "withdraw", 32);
        
        account.printHistory();
    }
}

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