In: Computer Science
Create an application that calculates and displays the starting and ending monthly balances for a checking account and a savings account.
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.
void deposit(double amount)
The Withdrawable interface should include this method:
void withdraw(double amount)
And the Balanceable interface should include these methods:
double getBalance()
void setBalance(double amount)
sorry to bother i really appreciate the help could you explain step by step please and thank you.
Thanks for the question, the entire assignment is too large to be completed in the given time. I have written the following interfaces and classes, Can you please post a separate question asking to code the AccountBalanceApp and the Console class For now you go through the code and try to understand, comments given as you requested. ===================================================================== public interface Depositable { void deposit(double amount); }
=====================================================================
public interface Withdrawable { void withdraw(double amount); }
=====================================================================
public interface Balanceable { double getBalance(); void setBalance(double amount); }
=====================================================================
//Create a class named Account that implements all three of these interfaces. public class Account implements Depositable, Withdrawable, Balanceable { //instance variable balance; private double balance; public Account() { balance = 0.0; } public Account(double balance) { this.balance = balance; } @Override public double getBalance() { return balance; } @Override public void setBalance(double amount) { balance = amount; } @Override public void deposit(double amount) { balance += amount; } @Override public void withdraw(double amount) { balance -= amount; } }
=====================================================================
//Create a class named CheckingAccount that inherits the Account class. public class CheckingAccount extends Account { private double monthlyFees; public CheckingAccount(double monthlyFees) { this.monthlyFees = monthlyFees; } public CheckingAccount(double balance, double monthlyFees) { super(balance); this.monthlyFees = monthlyFees; } // //This class should also include methods that subtract // // the monthly fee from the account balance and return the monthly fee. public double deductMonthlyFees() { withdraw(monthlyFees); return monthlyFees; } }
=====================================================================
//Create a class named SavingsAccount that inherits the Account class. public class SavingsAccount extends Account { private double monthlyInterestRate; private double interestPayment; //The monthly interest rate should be initialized to the value that’s passed to the constructor. public SavingsAccount(double monthlyInterestRate) { this.monthlyInterestRate = monthlyInterestRate; } //The monthly interest rate should be initialized to the value that’s passed to the constructor. public SavingsAccount(double balance, double monthlyInterestRate) { super(balance); this.monthlyInterestRate = monthlyInterestRate; } // The monthly interest payment should be calculated by a method that applies the // payment to the // account balance. public void addInterest(){ deposit(getBalance()*monthlyInterestRate); } //This class should also include a method that returns the monthly interest payment. public double getMonthlyInterestPayment() { return interestPayment; } }
=====================================================================