Write a program where you create a class called bankaccount

Assignment Help Programming Languages
Reference no: EM131307708

Write a program where you 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: EM131307708

Questions Cloud

Create a sales page that users see when they first access : You do not need to know HTML tags to use Web page creation tools. Typically, a professional Web site developer will create a sales page that users see when they first access the site.
Plot the output voltage of the line : The receiving gate is represented at its input by 10 pF. Because of the capacitive load, this would be a difficult problem to do by hand. Use SPICE (PSPICE) to plot the output voltage of the line, VL(t), for 0
Create diagram of dsl and cable modem connection to your isp : Create a diagram of the DSL and Cable Modem connections to your ISP, cable organization, and telecom to your home router using Visio or its open source alternative software.
Define the security strategies of defense in depth security : In this paper, you will define the security strategies of Defense in Depth and Layered Security along with comparing and contrasting the strategies by explaining.
Write a program where you create a class called bankaccount : Write a program where you 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.
What is conflict management : What is conflict management.watch the video lecture below to learn why conflict at work isn't always a bad thing.
Implement the fdtd method in a matlab program : ECE 452 - Assignment Give a FD discretization of the wave equation for an interior node (i, j) - Derive the FD equations for nodes on the left, right, top and bottom boundaries - Derive the stability condition for each of the above time discretizatio..
Find the price elasticity of demand for newtons donuts : Calculate the price elasticity of demand for Newton's Donuts and describe what it means. Describe your answer and show your calculations.
Explain effective approaches to the broad spectrum : Explain effective approaches to the broad spectrum of employee relations, including career development, fostering ethical behavior, discipline, labor relations, and dismissals.

Reviews

Write a Review

Programming Languages Questions & Answers

  Create a third subclass called phone

Key in the PolyMain, Book, Almanac, and Novel classes defined in this module of the course. Once you get each of these classes keyed in, make sure they compile and execute properly.

  Prepare a computer program to simulate the traffic

Write a computer program to simulate the traffic on a 2D plane under different traffic light control schemes.

  How to analyze the data

What kind of tools can help you to accomplish that

  Create the behavioral vhdl model for thirty two-bit alu

Create the behavioral VHDL model for 32-bit ALU. The ALU has 4-bit "op" control singal. Relationship between the "op" and operations of ALU.

  You will have to override some of the step-by-step procedure

Actually the author has not asked you to develop any new page here except that you will need to apply your external style sheet in your Index and Yurts pages done in Assignment 1A.

  Describe two other techniques for validating your document

This week covered validation and the use of validators. Describe at least two other techniques for validating your document that does not involve submitting it through an online validator.

  Create a java application for employee class

Create a Java application, that support the following:- Create an Employee class, which holds following information: Employee First Name, Employee Last Name.

  Discuss few web service tools

We have discussed a few web service Following are the Unit testing tools. In your opinion, are they really useful?

  Find out probability at any given time user transmitting

Assume there are 20 users. Determine probability that at any given time, exactly n users are transmitting simultaneously. Determine the probability that there are 11 or more users transmitting simultaneously.

  Create a model using the entities movie

Create a model to represent this report using the entities MOVIE, THEATER, and SHOW_TIME. Assume that theaters may show multiple movies.

  Write program to calculate diameter in centimeters of rod

Write program to calculate diameter in centimeters of a steel rod, an aluminum rod, and a copper rod, which can withstand a particular compression load.

  You can always add a compareto method to a class without

q1. you can always add a compareto method to a class without making it implement the comparable interface so why do you

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