Create a class called bank account

Assignment Help Business Management
Reference no: EM13764476

Bank Account Program

Create a class called BankAccount. The BankAccount class should contain a String to store the customer name and a double to store the account balance. The BankAccount class should have two constructors, as follows:

public BankAccount(String name, double balance)

throws NegativeAmountException

{

// set name and balance

// make sure balance is not negative

// throw exception if balance is negative

}

public BankAccount(String name)

throws NegativeAmountException

{

// set name and use 0 balance

}
As can be seen, the first constructor throws a NegativeAmountException if the balance being used to create the bank account is negative. You will have to create this exception class yourself.
The BankAccount class should also contain methods to make a deposit, make a withdrawal, get the current balance, and print a bank account statement. The interfaces for these methods should appear as follows:
// update balance by adding deposit amount

// make sure deposit amount is not negative

// throw exception if deposit is negative

public void deposit(double amount) throws NegativeAmountException

// update balance by subtracting withdrawal amount

// throw exception if funds are not sufficient

// make sure withdrawal amount is not negative

// throw NegativeAmountException if amount is negative

// throw InsufficientFundsException if balance < amount

public void withdraw(double amount)

throws InsufficientFundsException, NegativeAmountException

// return current balance

public double getBalance()

// print bank statement including customer name

// and current account balance

public void printStatement();
Use the BankAccount class as the superclass for a SavingsAccount class. In addition to the behaviors of a BankAccount, a SavingsAccount also accumulates interest; therefore, the SavingsAccount class contains a double that is populated with the current interest rate. In addition to its constructors (you decide what the constructors should be), the SavingsAccount class should contain the following methods:
// post monthly interest by multiplying current balance

// by current interest rate divided by 12 and then adding

// result to balance by making deposit

public void postInterest()

// print bank statement including customer name

// and current account balance (use printStatement from

// the BankAccount superclass)

// following this also print current interest rate

public void printStatement()
Once these two classes are completed, create a driver class called FinalExam containing a main method that tests the SavingsAccount class. Within the driver test class, create a SavingsAccount object and then use it to make deposits and withdrawals, and to post the monthly interest.
To make the program simpler, you can incorporate the initial data for the Savings Accounts directly in the program (e.g., no need to prompt for the account holder name or starting balance). The only things you need to prompt for are the deposit amount and the withdrawal amount. Also, to simplify the task, the only exceptions that you should handle are the NegativeAmountException and the InsufficientFundsException. If either of these exception conditions occurs, print an appropriate error message and terminate the application. You can simply re-throw any IOExceptions from the main.

Reference no: EM13764476

Questions Cloud

Criminal fraud versus civil fraud and taxation : Imagine a situation in which a client under audit by the IRS omitted $100,000 in income. From the e-Activity, examine the major factors relative to the omission by the client that would result in a criminal investigation, rather than a civil fraud..
Explain the decrease in criminal activity for young people : Your individual work assignment is to research and explain the decrease in criminal activity for young people after they pass through a period of adolescence
Sustainable approach to waste reduction developed : Analyze the sustainable approach to waste reduction developed - Previous methods of production
Compute the optimal order quantity using the eoq model : Compute the optimal order quantity using the EOQ model. Compute a) the number of orders per year and b) the annual relevant total cost of ordering and carrying inventory.
Create a class called bank account : Create a class called BankAccount. The BankAccount class should contain a String to store the customer name and a double to store the account balance. The BankAccount class should have two constructors, as follows:
Problem related to the contractual remedies : Haply Inc. contracts with Barksdale LLC to have an engine repaired. After much negotiation, the parties agree that the pump will be repaired and reinstalled at Haply's facilities in 5 days. Haply plans on losing $40,000 a day for each day the engi..
Water quality and contamination : Discuss the value of statistical significance vs. pragmatic usefulness.
Database development : Recommend at least three (3) specific tasks that could be performed to improve the quality of datasets, using the Software Development Life Cycle (SDLC) methodology. Include a thorough description of each activity per each phase.
Costs and revenues for the new product : Oakmont Company has an opportunity to manufacture and sell a new product for a four-year period. The company's discount rate is 16%. After careful study, Oakmont estimated the following costs and revenues for the new product:

Reviews

Write a Review

Business Management Questions & Answers

  Make recommendations regarding a business opportunity

Analyze the marketplace, competitive products/services and make recommendations regarding a business opportunity

  Supermarkets and discount stores with lumi cosmetics

Rita Sauer stocks several local supermarkets and discount stores with Lumi Cosmetics.

  What is strategicmanagemen

What is strategicmanagement? Why should youstudy strategic management? What is therelationship between strategic formulation and strategy implementation?

  Strategic managementinternal analysiscanon company1 please

strategic managementinternal analysiscanon company.1. please give a very short brief about canon internal analysis2.

  Illustrate what websites are helping you gain a better

namely the use of leading economic indicators to forecast the future direction of the macroeconomy. Illustrate what websites are helping you gain a better understanding of where the economy is heading in the next 12 months?

  Who are the owners of an openly traded company such as exxon

Who are the owners of an openly traded company such as Exxon-Mobil? and If the shares of a stock you own split 2-for-1 what must you expect to happen to the total value of your investment? Explain.

  Discuss the core values of an organization

Determine the core values of your organization and how did management estimate those core values? Are these written core values what you "see" in behaviors each day?

  Values in an organization influence ethical behaviour

Given that individual alterations in values in an organization influence ethical behaviour, explain how organizations can use this knowledge to increase ethical behaviour.

  Explain how many units must be started to allow

Explain how many units must be started to allow for loss due to scrap

  Reid wants to disaffirm the second-hand car loan

He formerly moved out of his apartment and into a friend's apartment. At the time he moved out Reid was one month past owing on his rent. Reid wants to disaffirm the second-hand car loan and the apartment lease

  Compute cp and cpk for this process and interpret

Compute Cp and Cpk for this process and interpret and suppose the process mean could be centered between the specification limits.

  Examine the five steps involved in developing a retail price

Examine the five steps involved in developing a retail price strategy. Select the step you trust to be critical to the success of the retailer and explain why.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd