Question

In: Computer Science

please, solve this problem.: implementing with java language create a bank account management system according to...

please, solve this problem.:

implementing with java language

create a bank account management system according to the following specifications:

BankAccount Abstract Class contains the following constructors and methods:

BankAccount(name, balance): a constructor that creates a new account with a name and starting balance.

getBalance(): a method that returns the balance of a specific account.

abstract deposit(amount): abstract method to be implemented in both Checking and SavingAccount classes.

abstract withdraw(amount): abstract method to be implemented in both Checking and SavingAccount classes.

messageTo Client (message): used to print a specific message to a client.

toString(): a method for printing accounts information.

CheckingAccount Class: A class that inherits from the Abstract Class BankAccount and implements both deposit () and withdraw ().

Deposit process in checking account has some constrains. Client can deposit any amount using checks and limit of $10,000.00 of cash deposit.

Client can withdraw any amount he wants.

SavingAccount Class: A class that inherits from the Abstract Class BankAccount and implements both deposit () and withdraw ().

A client can deposit any amount using checks and a limit of $5,000.00 of cash deposit. A 5% interest should be calculated on the total.

Client can only withdraw 20% of the total balance every 3 months.

Use interfaces for both checkingAccount and savingAccount classes.

BankAccountDriver class: this class is to test your code. The test should be done by creating an array of type BankAccount that stores different bank accounts types for different clients and perform some processing by calling the implemented methods on these accounts.

Solutions

Expert Solution

/*********************************BankAccount.java*********************************/

package bankaccount;

public abstract class BankAccount {

   /*
   * private data field
   */
   private String name;
   private double balance;

   /**
   *
   * @param name
   * @param balance
   */
   public BankAccount(String name, double balance) {
       super();
       this.name = name;
       this.balance = balance;
   }

   // getter and setter for balance
   public double getBalance() {
       return balance;
   }

   public void setBalance(double balance) {
       this.balance = balance;
   }

   public abstract void deposit(double amount);

   public abstract void withdraw(double amount);

   public void messageToClient() {

   }

   @Override
   public String toString() {
       return "BankAccount [name=" + name + ", balance=" + balance + "]";
   }

}
/****************************CheckingAccount.java****************************/

package bankaccount;

public class CheckingAccount extends BankAccount {

   /**
   *
   * @param name
   * @param balance
   */
   public CheckingAccount(String name, double balance) {
       super(name, balance);
   }

   @Override
   public void deposit(double amount) {

       if (amount <= 10000) {

           setBalance(getBalance() + amount);
       }
       else {
          
           System.out.println("You can only deposit 1000");
       }
   }

   @Override
   public void withdraw(double amount) {

       if (getBalance() > amount) {

           setBalance(getBalance() - amount);
       } else {

           System.out.println("Insufficient funds!");
       }
   }

}
/******************************SavingAccount.java**************************/

package bankaccount;

public class SavingAccount extends BankAccount {

   public SavingAccount(String name, double balance) {
       super(name, balance);

   }

   @Override
   public void deposit(double amount) {

       if (amount <= 5000) {

           setBalance(getBalance() + amount);
           double interest = getBalance() * .05;
           setBalance(getBalance() + interest);
       } else {

           System.out.println("Limit reached!");
       }

   }

   @Override
   public void withdraw(double amount) {

       if (amount < getBalance() * .2) {

           setBalance(getBalance() - amount);
       } else {

           System.out.println("You can't withdraw due to limit of saving account!");
       }
   }

}
/******************************BankAccountDriver.java***************************/

package bankaccount;

public class BankAccountDriver {

   public static void main(String[] args) {

       BankAccount[] bankAccounts = new BankAccount[3];
       // fill array with different accounts
       bankAccounts[0] = new CheckingAccount("Virat", 1000);
       bankAccounts[1] = new SavingAccount("Kohli", 2000);
       bankAccounts[2] = new CheckingAccount("MS", 3000);

       // do some operation on all account
       for (BankAccount bankAccount : bankAccounts) {

           bankAccount.deposit(5000);
           bankAccount.withdraw(1000);

       }

       // print information
       for (BankAccount bankAccount : bankAccounts) {

           System.out.println(bankAccount.toString());
       }
   }
}
/***************************output*******************************/

BankAccount [name=Virat, balance=5000.0]
BankAccount [name=Kohli, balance=6350.0]
BankAccount [name=MS, balance=7000.0]

Please let me know if you have any doubt or modify the answer, Thanks :)


Related Solutions

PROGRAMMING LANGUAGE : JAVA Problem specification. In this assignment, you will create a simulation for a...
PROGRAMMING LANGUAGE : JAVA Problem specification. In this assignment, you will create a simulation for a CPU scheduler. The number of CPU’s and the list of processes and their info will be read from a text file. The output, of your simulator will display the execution of the processes on the different available CPU’s. The simulator should also display: -   The given info of each process -   CPU utilization - The average wait time - Turnaround time for each process...
Using Java (Swing) language(please hard code)... Create a program that has a textfield for the user...
Using Java (Swing) language(please hard code)... Create a program that has a textfield for the user to type in a set of input. Below that textfield have the following controls to show string manipulations: (1) A button that will change the entire textfield’s current text to uppercase. (2) A button with its own textfield for a search value, that will tell the position the search value appears in the textfield above. (3) A button that reports the current number of...
solve the follwing problem. Bank reconciliation and entries The cash account for Pala Medical Co. at...
solve the follwing problem. Bank reconciliation and entries The cash account for Pala Medical Co. at June 30, 20Y1, indicated a balance of $146,035. The bank statement indicated a balance of $181,965 on June 30, 20Y1. Comparing the bank statement and the accompanying canceled checks and memos with the records revealed the following reconciling items: A. Checks outstanding totaled $16,445. B. A deposit of $9,900, representing receipts of June 30, had been made too late to appear on the bank...
solve the follwing problem. Bank reconciliation and entries The cash account for Pala Medical Co. at...
solve the follwing problem. Bank reconciliation and entries The cash account for Pala Medical Co. at June 30, 20Y1, indicated a balance of $146,035. The bank statement indicated a balance of $181,965 on June 30, 20Y1. Comparing the bank statement and the accompanying canceled checks and memos with the records revealed the following reconciling items: A. Checks outstanding totaled $16,445. B. A deposit of $9,900, representing receipts of June 30, had been made too late to appear on the bank...
JAVA LANGUAGE Required Tasks: In Eclipse, create a Java Project as CS-176L-Assign5. Create 3 Java Classes...
JAVA LANGUAGE Required Tasks: In Eclipse, create a Java Project as CS-176L-Assign5. Create 3 Java Classes each in its own file Student.java, StudentList.java, and Assign5Test.java. Copy your code from Assignment 4 into the Student.java and StudentList.java Classes. Assign5Test.java should contain the main method. Modify StudentList.java to use an ArrayList instead of an array. You can find the basics of ArrayList here: https://www.w3schools.com/java/java_arraylist.asp In StudentList.java, create two new public methods: The addStudent method should have one parameter of type Student and...
JAVA LANGUAGE Required Tasks: In Eclipse, create a Java Project as CS-176L-Assign4. Create 3 Java Classes...
JAVA LANGUAGE Required Tasks: In Eclipse, create a Java Project as CS-176L-Assign4. Create 3 Java Classes each in its own file Student.java, StudentList.java, and Assign4Test.java. Copy your code from Assignment 3 into the Student.java and StudentList.java. Assign4Test.java should contain the main method. In Student.java, add a new private variable of type Integer called graduationYear. In Student.java, create a new public setter method setGraduationYear to set the graduationYear. The method will have one parameter of type Integer. The method will set...
Answer the following in Java programming language Create a Java Program that will import a file...
Answer the following in Java programming language Create a Java Program that will import a file of contacts (contacts.txt) into a database (Just their first name and 10-digit phone number). The database should use the following class to represent each entry: public class contact {    String firstName;    String phoneNum; } Furthermore, your program should have two classes. (1) DatabaseDirectory.java:    This class should declare ArrayList as a private datafield to store objects into the database (theDatabase) with the...
Please Solve with c language Create 5-by-5 integer array. Initialize the elements of the array starting...
Please Solve with c language Create 5-by-5 integer array. Initialize the elements of the array starting from 1. Your element [0][0] should be equal to 1; element[4][4] should be equal 25. Print the array. The output should have 5 rows and 5 columns. Specify the width for each output to demonstrate the table in a formatted view. Change the value of the elements: 2nd row 4th column to 24, 1st row 3rd column to 13. Print the array again. Find...
(In C++) Bank Account Program Create an Account Class Create a Menu Class Create a main()...
(In C++) Bank Account Program Create an Account Class Create a Menu Class Create a main() function to coordinate the execution of the program. We will need methods: Method for Depositing values into the account. What type of method will it be? Method for Withdrawing values from the account. What type of method will it be? Method to output the balance of the account. What type of method will it be? Method that will output all deposits made to the...
Create a Scorekeeper app in android studio by using java language - Layouts | Widgets Create...
Create a Scorekeeper app in android studio by using java language - Layouts | Widgets Create the layout for your score keeping app. The app should have: Two team names (TextViews) Two scores (TextViews) Buttons to increase/ decrease the scores An amount to change the score by (RadioButtons) You must have at least two score options The scores can be changed by anything you want American football: 1, 2, 3, 6 Basketball: 1, 2, 3 Freestyle wrestling: 1, 2, 3,...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT