According to the following information, define Account, CheckingAccount, and TestPart1 classes. 1. Account and CheckingAccount classes Account - number: int - openDate: String - name: String - balance: double + Account(int, String, String, double) + deposit(double): void + withdraw (double): boolean + transferTo(Account, double): int + toString(): String CheckingAccount + CheckingAccount(int, String, String, double) + transferTo(Account, double): int Given the above UML diagam, define Account and CheckingAccount classes as follow: Account (8 points) • public Account(int nu, String op, String na, double ba): is a constructor and uses passed-in arguments to initialize instance variables. • public void deposit(double amount): updates the account balance using the passed-in amount. 2 • public boolean withdraw(double amount): if the amount is not more than the balance, updates the balance with the amount, and then returns true; otherwise, returns false. • public abstract int transferTo(Account account, double amount): is an abstract method. • public String toString(): returns all attribute values in this format, number<>openDate<>name<>balance, for example, 1001<>2018/6/21<>John Smith<>750.42 CheckingAccount (5 points) • This is a child class of Account and implements the transferTo() method as follows. • public int transferTo(Account account, double amount): the first argument is the beneficiary account, and the second argument is the transfer amount. This method transfers the money from this current account to the beneficiary account, and returns ? 0: transfer is successful and a $2 transfer fee is not applied ? 1: transfer is successful and the $2 transfer fee is applied ? -1: transfer is unsuccessful because balance is less than transfer amount and $2 transfer fee ? -2: transfer is unsuccessful because balance is less than transfer amount For our projects, the business rules are: ? If the balance of transferring account is $10000 or higher, a $2 transfer fee is waived. ? When making a transfer to a beneficiary account, if the balance of the transferring account is less than $10000, $2 transfer fee is deducted from the balance when the transfer occurs. ? If the balance is not sufficient to cover transfer amount (and the $2 transfer fee if the fee applies), the transfer should not occur. • public CheckingAccount(int nu, String op, String na, double ba): is a constructor and uses passed-in arguments to initialize instance variables. 2. TestPart1 class (7 points) • This class has the main() method. • You first creates a CheckingAccount object, and use the object to test deposit() and withdraw() methods, and use the toString() and System.out.println() to clearly display results for this CheckingAccount object after the deposit action and after the withdrawal action, respectively. • You can use hard-code values for deposit and withdrawal amounts and for Account and/or CheckingAccount attribute values. • Next, you create another CheckingAccount object, and test the transferTo() method. You can use hard-code values and use toString() and System.out.println() to clearly display results for the two CheckingAccount objects before and after the transfer action, respectively.
// Account class
package abc;
public abstract class Account {
private int number;
private String openDate;
private String name;
private double balance;
public Account(int number, String openDate, String name, double balance) {
this.number = number;
this.openDate = openDate;
this.name = name;
this.balance = balance;
}
public void deposit(double amount){
balance += amount;
}
public boolean withdraw(double amount){
if (!(amount>balance)){
balance -= amount;
return true;
}
else return false;
}
public abstract int transferTo(Account account, double amount);
@Override
public String toString() {
return number+"<>"+openDate+"<>"+name+"<>"+balance;
}
public int getNumber() {
return number;
}
public void setNumber(int number) {
this.number = number;
}
public String getOpenDate() {
return openDate;
}
public void setOpenDate(String openDate) {
this.openDate = openDate;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public double getBalance() {
return balance;
}
public void setBalance(double balance) {
this.balance = balance;
}
}
// CheckingAccount class
package abc;
public class CheckingAccount extends Account {
public CheckingAccount(int number, String openDate, String name, double balance) {
super(number, openDate, name, balance);
}
@Override
public int transferTo(Account account, double amount) {
if (this.getBalance() >= 10000) {
if (amount > this.getBalance()) {
return -2;
} else {
this.withdraw(amount);
account.deposit(amount);
return 0;
}
} else {
double totalPayableAmount = amount + 2;
if (totalPayableAmount > this.getBalance()) {
return -1;
} else {
this.withdraw(totalPayableAmount);
account.deposit(totalPayableAmount);
return 1;
}
}
}
}
//Test Part 1 class
package abc;
public class TestPart1 {
public static void main(String[] args){
CheckingAccount checkingAccount1 = new CheckingAccount(1, "3/7/2018", "testUser1", 9000);
//test withdraw and deposit
System.out.println(checkingAccount1.toString());
checkingAccount1.deposit(2000);
System.out.println(checkingAccount1.toString());
//withdraw
checkingAccount1.withdraw(500);
System.out.println(checkingAccount1.toString());
CheckingAccount checkingAccount2 = new CheckingAccount(2, "3/7/2018", "testUser2", 1000);
//before transfer
System.out.println("testUser1 :: " + checkingAccount1.toString());
System.out.println("testUser2 :: " + checkingAccount2.toString());
//transfer
checkingAccount1.transferTo(checkingAccount2, 5000);
//after tranfer
System.out.println("testUser1 post transfer :: " + checkingAccount1.toString());
System.out.println("testUser2 post transfer:: " + checkingAccount2.toString());
}
}
According to the following information, define Account, CheckingAccount, and TestPart1 classes. 1. Account and CheckingAccount classes...
/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ package checkingaccounttest; // Chapter 9 Part II Solution public class CheckingAccountTest { public static void main(String[] args) { CheckingAccount c1 = new CheckingAccount(879101,3000); c1.deposit(350); c1.deposit(220); c1.withdraw(100); c1.deposit(1100); c1.deposit(700); c1.withdraw(350); c1.withdraw(220); c1.withdraw(100); c1.deposit(1100); c1.deposit(700); c1.deposit(1000); System.out.println(c1); System.out.println("After calling computeMonthlyFee()"); c1.computeMonthlyFee(); System.out.println(c1); } } class BankAccount { private int...
*Step1: -Create UML of data type classes: reuse from lab3 for class Account, CheckingAccount and SavingAccount -Read the requirement of each part; write the pseudo-code in a word document by listing the step by step what you suppose to do in main() and then save it with the name as Lab4_pseudoCode_yourLastName *Step2: -start editor eClipse, create the project→project name: FA2019_LAB4PART1_yourLastName(part1) OR FA2019_LAB4PART2_yourLastName (part2) -add data type classes (You can use these classes from lab3) Account_yourLastName.java CheckingAccount_yourLastName.java SavingAccount_yourLastName.java -Add data structure...
TASK 1 Create a new class called CheckingAccount that extends BankAccount. It should contain a static constant FEE that represents the cost of clearing onecheck. Set it equal to 15 cents. Write a constructor that takes a name and an initial amount as parameters. Itshould call the constructor for the superclass. It should initializeaccountNumber to be the current value in accountNumber concatenatedwith -10 (All checking accounts at this bank are identified by the extension -10). There can be only one...
Use the Java codes below (Checking Account and Checking Account Demo), and work on these problems. You have to do both of your java codes based on the two provided Java codes. Create one method for depositing and one for withdrawing. The deposit method should have one parameter to indicate the amount to be deposited. You must make sure the amount to be deposited is positive. The withdraw method should have one parameter to indicate the amount to be withdrawn...
Write a Java class called BankAccount (Parts of the code is given below), which has two fields name (String) and balance (double), two constructors and five methods getName(), getBalance(), deposit (double amount), withdraw(double amount) and toString(). The first constructor should initialize name to null and balance to 0. The second constructor initializes name and balance to the parameters passed. deposit method deposits the amount to the account causing the current balance to increase, withdraw method withdraws the amount causing the...
Write a Java class called BankAccount (Parts of the code is given below), which has two fields name (String) and balance (double), two constructors and five methods getName(), getBalance(), deposit (double amount), withdraw(double amount) and toString(). The first constructor should initialize name to null and balance to 0. The second constructor initializes name and balance to the parameters passed. deposit method deposits the amount to the account causing the current balance to increase, withdraw method withdraws the amount causing the...
Requirements: Your Java class names must follow the names specified above. Note that they are case sensitive. See our template below. BankAccount: an abstract class. SavingAccount: a concrete class that extends BankAccount. o The constructor takes client's firstname, lastname and social security number. o The constructor should generate a random 6-digit number as the user account number. o The initial balance is 0 and the annual interest rate is fixed at 1.0% (0.01).o The withdraw method signature...
Point out errors in the following codes and correct them public class CheckingAccount { // Create attributes accountNum, Balance private int accountNum; // Account Number private double balance; // Account balance // Constructor public void CheckingAccount(int aNum, double balance) { // Call setters to initialize attribute values setAccountNumber(aNum); setBalance; } // Setters public void setAccountNumber(int aNum) { if (accountNum >= 100) { accountNum = aNum; }...
NOTE: Use the Account class codes in the section below these questions. Modify the main method in the CheckingAccountDemo class: Take out all previous code. Declare an object array with 10 accounts. Create a for loop to ask user to input each account’s information (name, account number, and initial balance) from keyboard and then initialize for each account object. Create a while loop to allow one to work on depositing and withdrawing operations on any account till one want to...
[JAVA] < Instruction> You are given two classes, BankAccount and ManageAccounts ManageAccounts is called a Driver class that uses BankAccount. associate a member to BankAcount that shows the Date and Time that Accounts is created. You may use a class Date. To find API on class Date, search for Date.java. Make sure to include date information to the method toString(). you must follow the instruction and Upload two java files. BankAccount.java and ManageAccounts.java. -------------------------------------------------------------------------- A Bank Account Class File Account.java...