Question

Java project: A Bank Transaction System For A Regional Bank User Story A regional rural bank...

Java project:

A Bank Transaction System For A Regional Bank User Story A regional rural bank CEO wants to modernize banking experience for his customers by providing a computer solution for them to post the bank transactions in their savings and checking accounts from the comfort of their home. He has a vision of a system, which begins by displaying the starting balances for checking and savings account for a customer. The application first prompts the user to enter the information for a transaction, including whether a withdrawal or deposit is to be made, whether the transaction will be posted to the checking or savings account, and the amount of the transaction. When the user (customer) finishes deposits and withdrawals, the application displays the fees and payments for the month followed by the final balances for the moth. The application needs to be friendly and it needs to validate the user entries. Operation • The application begins by displaying the starting balances for a checking and savings account. • The application prompts the user to enter the information for a transaction, including whether a withdrawal or deposit is to be made, whether the transaction will be posted to the checking or savings account, and the amount of the transaction. • When the user finishes entering deposits and withdrawals, the application displays the fees and payments for the month followed by the final balances for the month.

A typical customer interaction:

Welcome to the Account application
Starting Balances Checking: $1,000.00 Savings: $1,000.00
Enter the transactions for the month
Withdrawal or deposit? (w/d): w Checking or savings? (c/s): c Amount?: 500
Continue? (y/n): y
Withdrawal or deposit? (w/d): d Checking or savings? (c/s): s Amount?: 200
Continue? (y/n): n
Monthly Payments and Fees Checking fee: $1.00 Savings interest payment: $12.00
Final Balances Checking: $499.00 Savings: $1,212.00

Assumptions • There is no database for this system, that means nothing is stored or read from • The starting deposits are $1000 for both the accounts for each run. Banking fee is $1/month, and interest earned is 1%/month • Bank fee is flat fee and charged only once at the end of transactions for the checking account only • Interest earned is calculated only once for the balance left in the savings account only Requirement 1) The CEO of this bank has hired you. Your job is to write an object oriented Java program to provide the above experience, simulating a simplified banking experience. You need to identify the classes and its hierarchy (use inheritance). You should also have proper interfaces identified, which mandates all the required behaviors as described in the problem domain 2) Provide an application (user) class as well, which uses these classes to complete the user interaction. Your program needs to be idiot proof, meaning, you need to validate user entries and guide the user properly to enter correct information. 3) Overdraft is not allowed and final balance should not be negative for any accounts

0 0
Add a comment Improve this question Transcribed image text
Answer #1

AccountBalance.java


import java.text.NumberFormat;

public class AccountBalance {

    public static void main(String[] args) {

        CheckingAccount checkingAccount = new CheckingAccount(1.00);
        SavingsAccount savingsAccount = new SavingsAccount(0.01);

        checkingAccount.setBalance(1000.00);
        savingsAccount.setBalance(1000.00);

        NumberFormat currency = NumberFormat.getCurrencyInstance();

        Console.displayLine("Welcome to the Account application\n");
        Console.displayLine("Starting Balances");
        displayBalances(checkingAccount, savingsAccount);
        Console.displayLine();
        Console.displayLine("Enter the transactions for the month\n");

        String choice = "y";

        while (choice.equalsIgnoreCase("y")) {
            String transactionType = Console.getString("Withdrawal or deposit? (w/d): ", "w", "d");
            String accountType = Console.getString("Checking or savings? (c/s): ", "c", "s");
            double amount = Console.getDouble("Amount? ");

//            if (transactionType.equalsIgnoreCase("w")) {
//                amount = Console.getWithdrawalDouble("Amount? ");
//            } else {
//                amount = Console.getDouble("Amount? ");
//            }
            Console.displayLine();

            // code to perform transaction
            Account account = null;
            if (accountType.equalsIgnoreCase("c")) {
                account = checkingAccount;
            } else {
                account = savingsAccount;
            }

            if (transactionType.equalsIgnoreCase("w")) {
                if (amount > account.getBalance()) {
                    Console.displayLine("Amount entered exceeds account balance.\nPlease enter a valid amount.\n");
                } else {
                    account.withdraw(amount);
                }
            } else {
                account.deposit(amount);
            }

            choice = Console.getString("Continue? (y/n): ", "y", "n");
            Console.displayLine();
        }

        // apply interest and fees
        checkingAccount.subtractMonthlyFee();
        savingsAccount.setMonthlyIntPayment(savingsAccount.getBalance(), savingsAccount.getMonthlyIntRate());
        savingsAccount.applyPaymentToBalance();


        Console.displayLine("\nMonthly Payments and Fees");
        Console.displayLine("Checking Fee:                " + currency.format(checkingAccount.getMonthlyFee()));
        Console.displayLine("Savings Interest Payment:    " + currency.format(savingsAccount.getMonthlyIntPayment()));
        Console.displayLine();
        Console.displayLine("Final Balances");
        displayBalances(checkingAccount, savingsAccount);


    }

    private static void displayBalances(CheckingAccount ca, SavingsAccount sa) {
        NumberFormat currency = NumberFormat.getCurrencyInstance();
        Console.displayLine("Checking: " + currency.format(ca.getBalance()));
        Console.displayLine("Savings: " + currency.format(sa.getBalance()));
    }

}


CheckingAccount.java


public class CheckingAccount extends Account {
   double monthlyFee;

   public CheckingAccount(double fee) {
       monthlyFee = fee;
   }

   public double getMonthlyFee() {
       return monthlyFee;
   }
  
   public void subtractMonthlyFee () {
       setBalance(getBalance() - monthlyFee);
   }
}


SavingsAccount.java

public class SavingsAccount extends Account {
   double monthlyIntRate;
   double monthlyIntPayment;
  
   public SavingsAccount(double rate) {
       monthlyIntRate = rate;
   }

   public double getMonthlyIntRate() {
       return monthlyIntRate;
   }

   public void setMonthlyIntPayment(double balance, double rate) {
       monthlyIntPayment = balance * rate;
   }

   public double getMonthlyIntPayment() {
       return monthlyIntPayment;
   }
  
   public void applyPaymentToBalance() {
       setBalance(getBalance() + getMonthlyIntPayment());
   }
}


Account.java


public class Account implements Balancable, Withdrawable, Depositable {

   protected double balance = 0;

   @Override
   public void deposit(double amount) {
       // TODO Auto-generated method stub
       balance += amount;
   }

   @Override
   public void withdraw(double amount) {
       // TODO Auto-generated method stub
       balance -= amount;
   }

   @Override
   public double getBalance() {
       // TODO Auto-generated method stub
       return balance;
   }

   @Override
   public void setBalance(double amount) {
       // TODO Auto-generated method stub
       balance = amount;
   }
}


Balancable.java


public interface Balancable {
   double getBalance();
   void setBalance(double amount);
}


Withdrawable.java

public interface Withdrawable {
   void withdraw(double amount);
}


Console.java

import java.util.Scanner;

public class Console {

    private static Scanner sc = new Scanner(System.in);
  
    public static void displayLine() {
        System.out.println();
    }

    public static void displayLine(String s) {
        System.out.println(s);
    }

    public static String getString(String prompt) {
        System.out.print(prompt);
        String s = sc.nextLine();
        return s;
    }
  
   public static String getString(String prompt, String s1, String s2) {
       String s = "";
       System.out.print(prompt);
      
       boolean isValid = false;
       while (!isValid) {
           s = sc.next();
           if(s.equalsIgnoreCase(s1) || s.equalsIgnoreCase(s2)) {
               isValid = true;
           } else {
               System.out.println("Error! This entry is required. Try again.");
           }
           sc.nextLine();          
       }
       return s;
   }

    public static int getInt(String prompt) {
        int i = 0;
        while (true) {
            System.out.print(prompt);
            try {
                i = Integer.parseInt(sc.nextLine());
                break;
            } catch (NumberFormatException e) {
                System.out.println("Error! Invalid integer. Try again.");
            }
        }
        return i;
    }
  
    public static int getInt(Scanner sc, String prompt) {
        int i = 0;
        boolean isValid = false;
        while (!isValid) {
            System.out.print(prompt);
            if (sc.hasNextInt()) {
                i = sc.nextInt();
                isValid = true;
            } else {
                System.out.println("Error! Invalid integer value. Try again.");
            }
            sc.nextLine(); // discard any other data entered on the line
        }
        return i;
    }

    public static int getInt(Scanner sc, String prompt,
            int min, int max) {
        int i = 0;
        boolean isValid = false;
        while (!isValid) {
            i = getInt(sc, prompt);
            if (i <= min) {
                System.out.println(
                        "Error! Number must be greater than " + min + ".");
            } else if (i >= max) {
                System.out.println(
                        "Error! Number must be less than " + max + ".");
            } else {
                isValid = true;
            }
        }
        return i;
    }

    public static double getDouble(String prompt) {
        double d = 0;
        while (true) {
            System.out.print(prompt);
            try {
                d = Double.parseDouble(sc.nextLine());
                break;
            } catch (NumberFormatException e) {
                System.out.println("Error! Invalid decimal. Try again.");
            }
        }
        return d;
    }
  
  
    public static double getDouble(Scanner sc, String prompt) {
        double d = 0.0;
        boolean isValid = false;
        while (!isValid) {
            System.out.print(prompt);
            if (sc.hasNextDouble()) {
                d = sc.nextDouble();
                isValid = true;
            } else {
                System.out.println("Error! Invalid decimal value. Try again.");
            }
            sc.nextLine(); // discard any other data entered on the line
        }
        return d;
    }

    public static double getDouble(Scanner sc, String prompt,
            double min, double max) {
        double d = 0.0;
        boolean isValid = false;
        while (!isValid) {
            d = getDouble(sc, prompt);
            if (d <= min) {
                System.out.println(
                        "Error! Number must be greater than " + min + ".");
            } else if (d >= max) {
                System.out.println(
                        "Error! Number must be less than " + max + ".");
            } else {
                isValid = true;
            }
        }
        return d;
    }


Depositable.java


public interface Depositable {
   void deposit (double amount);
}


Add a comment
Know the answer?
Add Answer to:
Java project: A Bank Transaction System For A Regional Bank User Story A regional rural bank...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Project 9-2: Account Balance Calculator Create an application that calculates and displays the starting and ending...

    Project 9-2: Account Balance Calculator Create an application that calculates and displays the starting and ending monthly balances for a checking account and a savings account. --->Console Welcome to the Account application Starting Balances Checking: $1,000.00 Savings:  $1,000.00 Enter the transactions for the month Withdrawal or deposit? (w/d): w Checking or savings? (c/s): c Amount?: 500 Continue? (y/n): y Withdrawal or deposit? (w/d): d Checking or savings? (c/s): s Amount?: 200 Continue? (y/n): n Monthly Payments and Fees Checking fee:              $1.00 Savings...

  • ****USING PYTHON***** Write a program to simulate a bank transaction. There are two bank accounts: checking...

    ****USING PYTHON***** Write a program to simulate a bank transaction. There are two bank accounts: checking and savings. First, ask for the initial balances of the bank accounts; reject negative balances. Then ask for the transactions; options are deposit, withdrawal, and transfer. Then ask for the account; options are checking and savings. Reject transactions that overdraw an account. At the end, print the balances of both accounts

  • You have been hired as a programmer by a major bank. Your first project is 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, and balance inquiries. The application consists of the following functions:  N- New account  W- Withdrawal  D- Deposit  B- Balance  Q- Quit  X- Delete Account Use the following...

  • The Checking account is interest free and charges transaction fees. The first two monthly transactions are...

    The Checking account is interest free and charges transaction fees. The first two monthly transactions are free. It charges a $3 fee for every extra transaction (deposit, withdrawal). The Gold account gives a fixed interest at 5% while the Regular account gives fixed interest at 6%, less a fixed charge of $10. Whenever a withdrawal from a Regular or a Checking account is attempted and the given value is higher than the account's current balance, only the money currently available...

  • Should be in C# Create an inheritance hierarchy that a bank might use to represent customers’...

    Should be in C# Create an inheritance hierarchy that a bank might use to represent customers’ bank accounts. All customers at this back can deposit (i.e. credit) money into their accounts and withdraw (i.e. debit) money from their accounts. More specific types of accounts also exist. Savings accounts, for instance, earn interest on the money they hold. Checking accounts, on the other hand, charge a fee per transaction. Create base class Account and derived classes SavingsAccount and CheckingAccount that inherit...

  • must be written in c# using windows application Scenario: Samediff bank has a 25-year old banking...

    must be written in c# using windows application Scenario: Samediff bank has a 25-year old banking account system. It was created using procedural programming. Samediff bank needs to improve the security and maintainability of the system using an object-oriented programming (OOP) approach. Their bank manager has decided to hire you to develop, implement, and test a new OOP application using efficient data structures and programming techniques.Samediff banks manager is excited to consider updating their account system. An expert has advised...

  • Question 2 Bank reconciliations and cash It is now January 2020, and Harry Smith has come...

    Question 2 Bank reconciliations and cash It is now January 2020, and Harry Smith has come to you for some assistance as he is having trouble reconciling the bank account as at 31 December 2019.The December 2019 bank statement appeared as follows: Bank statement for December 2019: Date Description Deposit Withdrawal Balance 1/12/2019 Opening balance $14,550.00 1/12/2019 Loan application fee 300.00 $14,250.00 2/12/2019 EFT - Harry Smith Drawings 1,000.00 $13,250.00 5/12/2019 Deposit 1,650.00 $14,900.00 5/12/2019 Cheque 43 440.00 $14,460.00 11/12/2019...

  • Design a class named BankAccount containing the following data field and methods. • One double data...

    Design a class named BankAccount containing the following data field and methods. • One double data field named balance with default values 0.0 to denote the balance of the account. • A no-arg constructor that creates a default bank account. • A constructor that creates a bank account with the specified balance.  throw an IllegalArgumentException when constructing an account with a negative balance • The accessor method for the data field. • A method named deposit(double amount) that deposits...

  • Design a bank account class named Account that has the following private member variables:

    Need help please!.. C++ programDesign a bank account class named Account that has the following private member variables: accountNumber of type int ownerName of type string balance of type double transactionHistory of type pointer to Transaction structure (structure is defined below) numberTransactions of type int totalNetDeposits of type static double.The totalNetDeposits is the cumulative sum of all deposits (at account creation and at deposits) minus the cumulative sum of all withdrawals. numberAccounts of type static intand the following public member...

  • GREAT START COMMUNITY BANK Savings Rates Regular Passbook Interest Rates 0.10% **Money Market Savings or Checking...

    GREAT START COMMUNITY BANK Savings Rates Regular Passbook Interest Rates 0.10% **Money Market Savings or Checking Plus Savings Checking $50,000 or greater 0.30% 0.20% $25,000 to $49,999 0.20% 0.10% $10,000 to $24,999 0.10% 0.10% $1,000 to $9,999 0.10% 0.10% **Balances below $1,000 earn the regular Passbook Rate. **Fees could reduce earnings on accounts. **Certificates of Deposit ($500 minimum) A.P.Y. Interest Rate 31-day CD 0.10% 0.099% 32-day to 179-day CD 0.10% 0.099% 6-month CD 0.25% 0.249% 1-year CD 0.50% 0.499% 18-month...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT