JAVA PROGRAMMING LANGUAGE!!!!
JAVA PROGRAMMING LANGUAGE!!!!
JAVA PROGRAMMING LANGUAGE!!!!
Bank Account and Savings Account Classes
Design an abstract class named BankAccount to hold the following data for a bank account:
• Balance
• Number of deposits this month
• Number of withdrawals
• Annual interest rate
• Monthly service charges
The class should have the following methods:
Constructor: The constructor should accept arguments for the balance and annual interest rate.
deposit: A method that accepts an argument for the amount of the deposit The method should add the argument to the account balance. It should also increment the variable holding the number of deposits.
Withdraw: A method that accepts an argument for the amount of the with drawal. The method should subtract the argument from the balance. It should also increment the variable holding the number of withdrawals.
caleInterest: A method that updates the balance by calculating the monthly interest earned by the account, and adding this interest to the balance. This is performed by the following formulas:
Monthly Interest Rate = (Annual Interest Rate /12) Monthly Interest = Balance * Monthly Interest Rate
Balance = Balance + Monthly Interest
monthlyProcess: A method that subtracts the monthly service charges from the balance, calls the calcInterest method, and then sets the variables that hold the number of withdrawals, number of deposits, and monthly service charges to zero.
Next, design a Savings Account class that extends the BankAccount class. The Savings Account class should have a status field to represent an active or inactive account. If the balance of a savings account falls below $25, it becomes inactive. The status field could be a boolean variable.) No more withdrawals may be made until the balance is raised above $25, at which time the account becomes active again. The savings account class should have the following methods:
Withdraw: A method that determines whether the account is inactive before a withdrawal is made. (No withdrawal will be allowed if the account is not active.) A withdrawal is then made by calling the superclass version of the method.
Deposit: A method that determines whether the account is inactive before a deposit is made. If the account is inactive and the deposit brings the balance above $25, the account becomes active again. A deposit is then made by calling the superclass version of the method.
monthlyProcess: Before the superclass method is called, this method checks the num ber of withdrawals. If the number of withdrawals for the month is more than 4, a service charge of $1 for each withdrawal above 4 is added to the superclass field that holds the monthly service charges. (Don't forget to check the account balance after the service charge is taken. If the balance falls below $25, the account becomes inactive.)
ALSO INCLUDE THE FOLLOWING CLASSES
BANK.java
BankAccount.java
SavingsAccount.java
Code:
import java.text.DecimalFormat;
public class Driver
{
public static void main(String[] args)
{
// Create a Decimalformat object for formatting output.
DecimalFormat dollar = new DecimalFormat("$#,##0.00");
// Create a SavingsAccount object with a $100 balance,
// 3% interest rate, and a monthly service charge
// of $2.50.
SavingsAccount savings =
new SavingsAccount(100.0, 0.03, 2.50);
// Display what we've got.
System.out.println("Balance: " +
dollar.format(savings.getBalance()));
System.out.println("Number of deposits: " +
savings.getNumDeposits());
System.out.println("Number of withdrawals: " +
savings.getNumWithdrawals());
System.out.println();
// Make some deposits.
savings.deposit(25.00);
savings.deposit(10.00);
savings.deposit(35.00);
// Display what we've done so far.
System.out.println("Balance: " +
dollar.format(savings.getBalance()));
System.out.println("Number of deposits: " +
savings.getNumDeposits());
System.out.println("Number of withdrawals: " +
savings.getNumWithdrawals());
System.out.println();
// Make some withdrawals.
savings.withdraw(100.00);
savings.withdraw(50.00);
savings.withdraw(10.00);
savings.withdraw(1.00);
savings.withdraw(1.00);
// Display what we've done so far.
System.out.println("Balance: " +
dollar.format(savings.getBalance()));
System.out.println("Number of deposits: " +
savings.getNumDeposits());
System.out.println("Number of withdrawals: " +
savings.getNumWithdrawals());
System.out.println();
// Do the monthly processing.
savings.monthlyProcess();
// Display what we've done so far.
System.out.println("Balance: " +
dollar.format(savings.getBalance()));
System.out.println("Number of deposits: " +
savings.getNumDeposits());
System.out.println("Number of withdrawals: " +
savings.getNumWithdrawals());
}
}
--------------------------------------------------------------------------------------------------------------
public abstract class BankAccount {
// The total number of deposits.
private int numDeposits;
// The total number of withdrawals.
private int numWithdrawals;
// The current account balance.
private double balance;
// The annual interest rate. Expressed in decimal form.
private double interestRate;
// The monthly service charges. Reset at the end of the
month.
private double monthlyServiceCharge;
public BankAccount(double bal, double intRate, double mon){
this.balance = bal;
this.interestRate = intRate;
this.monthlyServiceCharge = mon;
}
// Adds funds to the balance.
public void deposit(double amount){
balance += amount;
numDeposits++;
}
// Deducts funds from the balance.
public void withdraw(double amount){
balance -= amount;
numWithdrawals++;
}
// Calculate interest on the account balance.
private void calcInterest(){
balance += balance * (interestRate / 12);
}
// Closes the monthly cycle and prepares the account for the
next month.
public void monthlyProcess(){
balance -= monthlyServiceCharge;
calcInterest();
numDeposits = 0;
numWithdrawals = 0;
monthlyServiceCharge = 0;
}
// Sets a new monthly service charge amount.
public void setMonthlyServiceCharges(double amount){
monthlyServiceCharge = amount;
}
// Returns the account balance.
public double getBalance(){
return balance;
}
// Returns the total number of deposits.
public int getNumDeposits(){
return numDeposits;
}
// Returns the total withdrawals for the month.
public int getNumWithdrawals(){
return numWithdrawals;
}
// Returns the annual interest rate.
public double getInterestRate(){
return interestRate;
}
//Returns the current monthly service charge.
public double getMonthlyServiceCharges(){
return monthlyServiceCharge;
}
}
-----------------------------------------------------------------------------------------------------------
public class SavingsAccount extends BankAccount{
// current status of the account.
private boolean status;
public SavingsAccount(double bal, double intRate, double
mon){
super(bal, intRate, mon);
status = true;
}
// Confirms account is active, then deducts funds from balance.
@Override
public void withdraw(double amount){
if(status){
super.withdraw(amount);
}
if(super.getBalance() < 25){
status = false;
}
}
// Confirms the account is active, then adds funds to the balance.
@Override
public void deposit(double amount){
if(status || super.getBalance() + amount > 25){
super.deposit(amount);
status = true;
}
}
// Closes the monthly cycle and prepares the account for the next month.
@Override
public void monthlyProcess(){
if(super.getNumWithdrawals() > 4){
super.setMonthlyServiceCharges(super.getMonthlyServiceCharges()
+
(super.getNumWithdrawals() - 4));
}
super.monthlyProcess();
if(super.getBalance() < 25){
status = false;
}
}
}
JAVA PROGRAMMING LANGUAGE!!!! JAVA PROGRAMMING LANGUAGE!!!! JAVA PROGRAMMING LANGUAGE!!!! Bank Account and Savings Account Classes Design...
Must be in GUI interfaceDesign an abstract class namedBankAccountto hold the following data for a bankaccount:* Balance* Number of deposits this month* Number of withdrawals (this month)* Annual interest rate* Monthly service chargesThe class should have the following methods:Constructor: The constructor should accept arguments for the balance and annual interest rate.deposit: A method that accepts an argument for the amount of the deposit. The methods should add the argument to the account balance. It should also increment thevariable holding the...
Design and implement the following 3 classes with the exact fields and methods (these names and caps exactly): 1. An abstract class named BankAccount (java file called BankAccount.java) Description Filed/Method Balance NumberDeposits NumberWithdrawals AnnualInterestRate MonthlyServiceCharge BankAccount SetHonthlyServiceCharges A method that accepts the monthly service charges as an argument and set the field value GetBalance GetNum berDeposits GetNum berWithdrawals GetAnnualinterestRate GetMonthlyServiceCharge A method that returns the monthly service charge Deposit field for the bank account balance A field for the number...
pls write psuedocode
write UML CODE
ALSO
example 3 files 1 for abstract 1 for bank account and
1 for savings accounts due in 12 hours
Lab Assignment 4a Due: June 13th by 9:00 pm Complete the following Programming Assignment. Use good programming style and all the concepts previously covered. Submit the java files electronically through Canvas by the above due date in 1 Zip file Lab4.Zip. (This is from the chapter on Inheritance.) 9. BankAccount and SavingsAccount Classes Design...
the
programing language is C++
TIC PEO. Design a generic class to hold the following information about a bank account! Balance Number of deposits this month Number of withdrawals Annual interest rate Monthly service charges The class should have the following member functions: Constructor: Accepts arguments for the balance and annual interest rate. deposit: A virtual function that accepts an argument for the amount of the deposit. The function should add the argument to the account balance. It should also...
please rewrite this code as Pseudo-Code,.. basically rewrite the code but in english language , Thank you so much! public abstract class BankAccount { //declare the required class variables private double balance; private int num_deposits; private int num_withdraws; private double annualInterest; private double serviceCharges; //constructor that takes two arguments // one is to initialize the balance and other // to initialize the annual interest rate public BankAccount(double balance,...
PYTHON PROGRAMMING LANGUAGE
Design a class named Savings Account that contains: A private int data field named id for the savings account. A private float data field named balance for the savings account. A private float data field named annuallnterestRate that stores the current interest rate. A_init_ that creates an account with the specified id (default 0), initial balance (default 100), and annual interest rate (default 0). . The accessor and mutator methods for id, balance, and annuallnterestRate. A method...
Question 2 Programming by Contract (a) Design a BankAccount class for maintaining bank balances. Each bank account should have a current balance and methods implementing deposits and withdrawals; however money can only be withdrawn from an account if there are sufficient funds. Each account has a cash withdrawal limit of $800 per day. Give Java implementations of the methods in your design. Explain how your implementation enforces the daily limit on withdrawals. (b) Give preconditions and postconditions for each method...
solve this JAVA problem in NETBEANS
Problem #12 in page 400 of your text (6th edition): SavingsAccount Class. Design a SavingsAccount class that stores a savings account's annual interest rate and balance. The class constructor should accept the amount of the savings account's starting balance. The class should also have methods for subtracting the amount of a withdrawal, adding the amount of a deposit, and adding the amount of monthly twelve. To add the monthly interest rate to the balance,...
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...