For Java: = 0){if( balancebalance -- amount;return true;}else{return false;}}* Get the balance* @return the balance*/public double getBalance(){return balance;}* Set account ID* @param...


For Java:


Bank Accounts 01: Child Classes<br>Copy the following SimpleBankAccount class and use it as a base class:<br>Simple representation of a bank account<br>* @author Hyrum D. Carroll<br>* @version 0.5 (10/12/2020)<br>import java.text.NumberFormat;<br>public class SimpleBankAccount{<br>// fields (instance variables)<br>private double balance;<br>private string accountId;<br>/**<br>* Constructor for objects of class SimpleBankAccount<br>*/<br>public SimpleBankAccount(O{<br>balance = 0.0;<br>accountId = = 0){ if( balance balance -- amount; return true; }else{ return false; } } * Get the balance * @return the balance */ public double getBalance(){ return balance; } * Set account ID * @param the account ID */ public void setAccountId(String id){ accountId = id; * Get the account ID * @return the account ID */ public String getAccountId(O{ return accountId; } * Produces a string represenation of the balance * @return The balance (with a label) public String tostring( ){ // display balance as currency string balancestr = NumberFormat.getcurrencyInstance().format( balance ); return "Balance for account " + accountId + ": " + balancestr + "\n"; } Include at least two classes: CheckingAccount and SavingsAccount. Save your CheckingAccount class in a file named CheckingAccount.java and your SavingsAccount class in a file named SavingsAccount.java. Your CheckingAccount class needs to add a field to track the last processed check number. Also include both a no-argument constructor and a parameterized constructor (that takes a double and a String). Furthermore, include the following method: public boolean processcheck( int checkNum, double amount ); which returns false if checkNum has the same check number as the last check processed, otherwise it reduces the balance by amount and returns true. Your SavingsAccount class needs to have a field for the interest rate. Also include both a constructor that just takes the interest rate (as a double) and a parameterized constructor (that takes a double, String and a double). Furthermore, include an applyInterest () method that multiples the current balance by the interest rate, and adds that to the balance. The following code should work and produce the output below: Exercises the basic functionality of a Checking and SavingsAccount @author Hyrum D. Carroll @version 0.3 (10/12/2020) */ public class AccountsDriver{ public static final double INTEREST_RATE = 0.01; // 1% public static void main( string[] args ){ CheckingAccount checking = new CheckingAccount( 100.0, "checking123" ); SavingsAccount savings = nev Saving sAccount( 1000.0, "savings124", INTEREST_RATE ); double monthlyExpenses = 756.34; int electricBillcheckNum = 2123; double electricBill = 60.34; int registationCheckNum = 2124; double registration = 50.00; double dinnerMoney 55.32; double futurecar = 200.0; double textbook = 90.0; // checking account transactions checking.deposit( monthlyExpenses ); checking.processcheck( electricBillcheckNum, electricBil1 ); checking.withdraw( dinnerMoney ); checking.processcheck( registationCheckNum, registration ); system.out.print( checking.tostring () ); System.out.println( ); // savings account transactions savings.deposit( futurecar ); savings.applyInterest( ); savings.withdraw( textbook ); System.out.print( savings.tostring() ); system.out.println( ); } } Output: Checking Account: Balance for account checking123: $698.68 Last processed check number: 2124 Savings Account: Balance for account savings124: $1,122.00 APR: 1.0% Make just the necessary changes to the code in SimpleBankAccount to complete the instructions. Submit the following files: • CheckingAccount.java • SavingsAccount.java • SimpleBankAccount.java "/>
Extracted text: Bank Accounts 01: Child Classes Copy the following SimpleBankAccount class and use it as a base class: Simple representation of a bank account * @author Hyrum D. Carroll * @version 0.5 (10/12/2020) import java.text.NumberFormat; public class SimpleBankAccount{ // fields (instance variables) private double balance; private string accountId; /** * Constructor for objects of class SimpleBankAccount */ public SimpleBankAccount(O{ balance = 0.0; accountId = ""; } * Constructor for objects of class SimpleBankAccount */ public SimpleBankAccount( double bal, string id ){ balance = bal; accountId = id; } * Add money to the balance * @param amount the amount to deposit * @return void */ public void deposit( double amount ) { balance += amount; } * Remove money from the balance * @param amount the amount to withdraw or false (failure) * @return true (success) */ public boolean withdraw( double amount ){ amount >= 0){ if( balance balance -- amount; return true; }else{ return false; } } * Get the balance * @return the balance */ public double getBalance(){ return balance; } * Set account ID * @param the account ID */ public void setAccountId(String id){ accountId = id; * Get the account ID * @return the account ID */ public String getAccountId(O{ return accountId; } * Produces a string represenation of the balance * @return The balance (with a label) public String tostring( ){ // display balance as currency string balancestr = NumberFormat.getcurrencyInstance().format( balance ); return "Balance for account " + accountId + ": " + balancestr + "\n"; } Include at least two classes: CheckingAccount and SavingsAccount. Save your CheckingAccount class in a file named CheckingAccount.java and your SavingsAccount class in a file named SavingsAccount.java. Your CheckingAccount class needs to add a field to track the last processed check number. Also include both a no-argument constructor and a parameterized constructor (that takes a double and a String). Furthermore, include the following method: public boolean processcheck( int checkNum, double amount ); which returns false if checkNum has the same check number as the last check processed, otherwise it reduces the balance by amount and returns true. Your SavingsAccount class needs to have a field for the interest rate. Also include both a constructor that just takes the interest rate (as a double) and a parameterized constructor (that takes a double, String and a double). Furthermore, include an applyInterest () method that multiples the current balance by the interest rate, and adds that to the balance. The following code should work and produce the output below: Exercises the basic functionality of a Checking and SavingsAccount @author Hyrum D. Carroll @version 0.3 (10/12/2020) */ public class AccountsDriver{ public static final double INTEREST_RATE = 0.01; // 1% public static void main( string[] args ){ CheckingAccount checking = new CheckingAccount( 100.0, "checking123" ); SavingsAccount savings = nev Saving sAccount( 1000.0, "savings124", INTEREST_RATE ); double monthlyExpenses = 756.34; int electricBillcheckNum = 2123; double electricBill = 60.34; int registationCheckNum = 2124; double registration = 50.00; double dinnerMoney 55.32; double futurecar = 200.0; double textbook = 90.0; // checking account transactions checking.deposit( monthlyExpenses ); checking.processcheck( electricBillcheckNum, electricBil1 ); checking.withdraw( dinnerMoney ); checking.processcheck( registationCheckNum, registration ); system.out.print( checking.tostring () ); System.out.println( ); // savings account transactions savings.deposit( futurecar ); savings.applyInterest( ); savings.withdraw( textbook ); System.out.print( savings.tostring() ); system.out.println( ); } } Output: Checking Account: Balance for account checking123: $698.68 Last processed check number: 2124 Savings Account: Balance for account savings124: $1,122.00 APR: 1.0% Make just the necessary changes to the code in SimpleBankAccount to complete the instructions. Submit the following files: • CheckingAccount.java • SavingsAccount.java • SimpleBankAccount.java
Jun 07, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here