Project 9-2: Account Balance Calculator
Create an application that calculates and displays the starting and ending monthly balances for a checking account and a savings account.
--->Console
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
Specifications
Create interfaces named Depositable, Withdrawable, and Balanceable that specify the methods that can be used to work with accounts. The Depositable interface should include this method:
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)
Create a class named Account that implements all three of these interfaces. This class should include an instance variable for the balance.
Create a class named CheckingAccount that inherits the Account class. This class should include an instance variable for the monthly fee that's initialized to the value that's passed to the constructor. This class should also include methods that subtract the monthly fee from the account balance and return the monthly fee.
Create a class named SavingsAccount that inherits the Account class. This class should include instance variables for the monthly interest rate and the monthly interest payment. The monthly interest rate should be initialized to the value that's passed to the constructor. The monthly interest payment should be calculated by a method that applies the payment to the account balance. This class should also include a method that returns the monthly interest payment.
Create a class named AccountBalanceApp that uses these objects to process and display deposits and withdrawals.
Use the Console class presented in book Murach's Java programming 5 the edition in chapter 7 or an enhanced version of it to get and validate the user's entries. Don't allow the user to withdraw more than the current balance of an account.
Code:
1) Withdrawable.java
package savingsaccountcurrentaccount;
public interface Withdrawable {
/**
* Withdraw.
*
* @param amount the amount
*/
void withdraw(double amount);
}
2) Depositable.java
package savingsaccountcurrentaccount;
public interface Depositable {
/**
* Deposit.
*
* @param amount the amount
*/
void deposit(double amount);
}
3) Balancable.java
package savingsaccountcurrentaccount;
public interface Balanceable {
double getBalance();
/**
* Sets the balance.
*
* @param amount the new balance
*/
void setBalance(double amount);
}
4) Account.java
/**
*
*/
package savingsaccountcurrentaccount;
/**
* @author PC
*
*/
public class Account implements Depositable, Withdrawable,
Balanceable {
private double balance;
/**
* default constructor
*/
public Account() {
super();
}
/*
* (non-Javadoc)
*
* @see savingsaccountcurrentaccount.Balanceable#getBalance()
*/
@Override
public double getBalance() {
return balance;
}
/*
* (non-Javadoc)
*
* @see
savingsaccountcurrentaccount.Balanceable#setBalance(double)
*/
@Override
public void setBalance(double amount) {
if (amount > 0)
this.balance = amount;
}
/*
* (non-Javadoc)
*
* @see
savingsaccountcurrentaccount.Withdrawable#withdraw(double)
*/
@Override
public void withdraw(double amount) {
if (amount > 0 && this.balance - amount > 0)
this.balance = this.balance - amount;
else {
System.out.println("Unable to withdraw, insufficient
funds..");
}
}
/*
* (non-Javadoc)
*
* @see
savingsaccountcurrentaccount.Depositable#deposit(double)
*/
@Override
public void deposit(double amount) {
if (amount > 0)
setBalance(this.balance + amount);
}
}
5) SavingsAccount.java
/**
*
*/
package savingsaccountcurrentaccount;
/**
* @author PC
*
*/
public class SavingsAccount extends Account {
private double monthlyIntrestRate;
private double monthlyIntrestPayment;
/**
*
* @param monthlyIntrestRate
*/
public SavingsAccount(double monthlyIntrestRate) {
super();
this.monthlyIntrestRate = monthlyIntrestRate;
}
/*
* returns monthly interest payment
*/
public double getMonthlyInterestPayment(){
return monthlyIntrestPayment;
}
/*
* calculates and sets the monthly interest payment
*/
private void setMonthlyInterestPayment(){
monthlyIntrestPayment = getBalance() * monthlyIntrestRate;
}
/*
* adds interest to balance
*/
public void addMonthlyInterest(){
setMonthlyInterestPayment();
setBalance(getBalance()+ monthlyIntrestPayment);
}
}
6) CheckingAccount.java
/**
*
*/
package savingsaccountcurrentaccount;
/**
* @author PC
*
*/
public class CheckingAccount extends Account {
private double monthlyFee;
/**
* @param monthlyFee
*/
public CheckingAccount(double monthlyFee) {
super();
this.monthlyFee = monthlyFee;
}
/*
* Deduces monthly charges from balance
*/
public void chargeMonthlyFee(){
setBalance(getBalance()- monthlyFee);
}
/**
* @return the monthlyFee
*/
public double getMonthlyFee() {
return monthlyFee;
}
}
7) AccountBalanceApp.java
/**
*
*/
package savingsaccountcurrentaccount;
import java.util.Scanner;
/**
* @author PC
*
*/
public class AccountBalanceApp {
/**
* @param args
*/
public static void main(String[] args) {
//for input
Scanner sc = new Scanner(System.in);
//creating objects of savings and checking accounts
SavingsAccount savings = new SavingsAccount(0.01);
CheckingAccount checking = new CheckingAccount(1);
//starting
System.out.println("Welcome to the Account Application");
char again = 'Y';
//asking for initial balances
System.out.println("Starting Balances");
System.out.print("Checking: $");
checking.deposit(sc.nextDouble());
System.out.print("Savings: $");
savings.deposit(sc.nextDouble());
System.out.println("Enter the transactions for the month");
//started taking monthly transactions
do {
char choice;
//taking choice
System.out.println("Withdrawal or deposit? (w/d): ");
choice = sc.next().charAt(0);
if (Character.toUpperCase(choice) == 'W') {//if withdrawal
//taking choice
System.out.println("Checking or savings? (c/s): ");
choice = sc.next().charAt(0);
if (Character.toUpperCase(choice) == 'C') { //for checking
System.out.println("Amount?: ");
checking.withdraw(sc.nextDouble());
} else if (Character.toUpperCase(choice) == 'S') { //for
savings
System.out.println("Amount?: ");
checking.withdraw(sc.nextDouble());
} else { //invalid
System.out.println("Invalid ! choice ");
}
} else if (Character.toUpperCase(choice) == 'D') { //if
deposit
//taking choice
System.out.println("Checking or savings? (c/s): ");
choice = sc.next().charAt(0);
if (Character.toUpperCase(choice) == 'C') { //for checking
System.out.println("Amount?: ");
checking.deposit(sc.nextDouble());
} else if (Character.toUpperCase(choice) == 'S') {//for
savings
System.out.println("Amount?: ");
savings.deposit(sc.nextDouble());
} else { //invalid
System.out.println("Invalid ! choice ");
}
} else { //invalid
System.out.println("Invalid ! choice try again");
}
//taking option
System.out.println("Continue? (y/n):");
again = sc.next().charAt(0);
} while (Character.toUpperCase(again) != 'N'); //loop till enterd
n/N
//adding monthly charges and interests
savings.addMonthlyInterest();
checking.chargeMonthlyFee();
//printing monthly summary
System.out.println("\nMonthly Payments and Fees");
System.out.printf("Checking fee:
$%.2f\n",checking.getMonthlyFee());
System.out.printf("Savings interest payment:
$%.2f\n",savings.getMonthlyInterestPayment());
System.out.println("Final Balances");
System.out.printf("Checking: $%.2f\n",checking.getBalance());
System.out.printf("Savings: $%.2f\n",savings.getBalance());
sc.close();
}
}
Output Screenshot:

Project 9-2: Account Balance Calculator Create an application that calculates and displays the starting and ending...
Should be in C#
Create an inheritance hierarchy that a bank might use to
represent customers’ bank accounts. All customers at this back can
deposit (i.e. credit) money into their accounts and withdraw (i.e.
debit) money from their accounts. More specific types of accounts
also exist. Savings accounts, for instance, earn interest on the
money they hold. Checking accounts, on the other hand, charge a fee
per transaction.
Create base class Account and derived classes SavingsAccount and
CheckingAccount that inherit...
The Account class Create a class named Account, which has the following private properties: number: long balance: double Create a no-argument constructor that sets the number and balance to zero. Create a two-parameter constructor that takes an account number and balance. First, implement getters and setters: getNumber(), getBalance(), setBalance(double newBalance). There is no setNumber() -- once an account is created, its account number cannot change. Now implement these methods: void deposit(double amount) and void withdraw(double amount). For both these methods,...
Code the following interfaces - An interface called Accountable with void withdraw(double) and double getPayment() methods, and an interface called AccountReceivable with a void deposit(double) method. Save these two interfaces in separate Java files. Then code a class, BusinessAccount, that implements the two interfaces defined above. Define and code the necessary instance variables and constructors. Override toString() so it will return the amount of a business account. Apply the particular operations, such as withdraw and deposit, required in implementing the...
For this week's assignment , please create an application following directions in the attached document.(windows form application) Create a base class named Account and derived classes named SavingsAccount and CheckingAccount that inherit from class Account. Base class Account should include one private instance variable of type decimal to represent the account balance. The class should provide a constructor that receives an initial balance and uses it to initialize the instance variable with a public property. The property should validate the...
Java Code the following interfaces - An interface called Accountable with void withdraw(double) and double getBalance() methods, and an interface called AccountReceivable with a void deposit(double) method. Save these two interfaces in separate Java files. Then code a class, BusinessAccount, that implements the two interfaces defined above. Define and code the necessary instance variables and constructors. Override toString() so it will return the amount of a business account. Apply the particular operations, such as withdraw and deposit, required in implementing...
In C++ Write a program that contains a BankAccount class. The BankAccount class should store the following attributes: account name account balance Make sure you use the correct access modifiers for the variables. Write get/set methods for all attributes. Write a constructor that takes two parameters. Write a default constructor. Write a method called Deposit(double) that adds the passed in amount to the balance. Write a method called Withdraw(double) that subtracts the passed in amount from the balance. Do not...
•create a new savings account object
(for choice 2).
•ask the user to enter an initial
balance which should be greater than 50. If the entered amount is
less than 50, the program will ask the user to enter another
amount. This continues until an amount greater than 50 is
entered.
•Set the balance of the savings account
object by calling the setBalance() method.
•Ask the user to deposit an amount.
Deposit that amount and display the balance of the...
Application should be in C# programming language
Create a class called SavingsAccount. Use a static
variable called annualInterestRate to store the annual interest
rate for all account holders. Each object of the class
contains a private instance variable savingsBalance, indicating the
amount the saver currently has on deposit. Provide method
CalculateMonthlyInterest to calculate the monthly interest by
multiplying the savingsBalance by annualInterestRate divided by 12
– this interest should be added to
savingsBalance. Provide static method
setAnnualInterestRate to set the...
IN JAVAThe code is attached below has the Account class that was designed to model a bank account. An account has the properties account number, balance, annual interest rate, and date created, and methods to deposit and withdraw funds. I need creat program using the 2 java programs.Create two subclasses for checking and savings accounts. A checking account has an overdraft limit, but a savings account cannot be overdrawn.I need to write a test program that creates objects of Account,...
In Java
Create an interface called
Amount
that includes a method called
setPrice
().
Create an abstract class named
Book
that inherits from the interface Amount. Include a String field
for
the book’s
title
and a double field for the book’s
Price
. Within the class, include a constructor that
requires the book title and add
two getter methods
— one that returns the title and one that returns the
price. Include an abstract method named
setPrice
().
Create a...