* Constructor for objects of class SimpleBankAccount public SimpleBankAccount (){ balance- 0.0; ac countid- ""; * Constructor for objects of cla SimpleBankAccount public SimpleBankAccount( double bal, string id ){ balance- bal; accountid - id; * Add money to the balance * @param amount the amount to deposit * Oreturn void public void deposit( double amount )( balance + amount; * Remove money from the balance * Oparam amount the amount to withdraw * @return true (success) or false (failure) public boolean withdraw( double amount ){ if( balance - amount > 0 ){ balance - amount; return true; Jelse{ return false: * Get the balance * Oreturn the balance public double getalance()( return balance; * Set account ID * @param the account ID public void setaccountId(String id){ accountId - id; * Get the account ID * Oreturn she account ID public String getAccountId()( return accountid; * Produces a string represenation of the balance * ereturn The balance (vith a label) public String tostring( )( // display balance as eurrency 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 checkllum 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 * Gauthor Hyrum D. Carroll * eversion 0.3 (10/12/2020) public clasas AccountsDriver( public static final double INTEREST_RATE - 0.01; // 14 public statie void main( String(] args ){ CheckingAccount checking - new Checkingaccount( 100.0, "checking123" ); SavingsAccount savings = new Saving SAccount( 1000.0, "savingsi24", INTEREST_RATE ); double monthlyExpenses - 756.34; int electricBillcheckNum = 2123; do uble electricsill = 60.34; int registationCheckNum- 21243; do uble registration = 50.00; double dinnerMoney- 55.32; double futurecar - 200.0; do uble textbook = 90.0; // checking account transactions checking.deposit( monthlyExpenses ); checking.processcheck( electriceillcheckNum, electriceil1 ); checking.withdraw( dinnerMoney ); checking.processcheck( registationCheckNum, registration ); System.out.print( checking.tostring () ); System.out.printin( ); // savinga 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: $690.68 Last processed check number: 2124 Savings ACcount: Balance for account savings124: $1,122.00 APR: 1.e% Make just the necessary changes to the code in SimpleBankAccount to complete the instructions. Submit the following files: • CheckingAcount.java

Programming Logic & Design Comprehensive
9th Edition
ISBN:9781337669405
Author:FARRELL
Publisher:FARRELL
Chapter11: More Object-oriented Programming Concepts
Section: Chapter Questions
Problem 15RQ
icon
Related questions
Topic Video
Question

For Java:

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
Transcribed Image 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
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps with 1 images

Blurred answer
Knowledge Booster
Instruction Format
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Programming Logic & Design Comprehensive
Programming Logic & Design Comprehensive
Computer Science
ISBN:
9781337669405
Author:
FARRELL
Publisher:
Cengage