Write a program where you create a class called bankaccount

Assignment Help Programming Languages
Reference no: EM13762609

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: EM13762609

Questions Cloud

Effective-interest method and plans : On January 1, 2013, King Corporation paid $705,186 to acquire 10% bonds with a face value of $750,000. The discount of $44,814 provides an effective yeld of 11%. King Corporation uses the effective-interest method and plans to hold these bonds to ..
Operations of information security : This assignment consists of two (2) sections: a written paper and a PowerPoint presentation. You must submit both sections as separate files for the completion of this assignment. Label each file name according to the section of the assignment it ..
Fundamental drivers of the fraud : Briefly describe the selected publicly traded company that committed fraud, and analyze the fundamental drivers of the fraud.
The major danger of hurricanes to coastal areas : The major danger of hurricanes to coastal areas and how has the federal government historically responded.
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.
Create a successful turnaround : Describe in detail, their organizational renewal strategies to create a successful turnaround. Compare the new corporate strategy to the old. Did it work?
Direct and indirect methods of preparing the statement : Contrast the advantages and disadvantages of the direct and indirect methods of preparing the statement of cash flows. Are both methods acceptable? Which method is preferred by the FASB? Which is more popular with businesses?
Explain the chain of analysis from payroll : Explain the chain of analysis from payroll to total points and then on to total points and revenue and what other factors might affect these relationships that are outside of the data looked at in this project?
Write the psuedocode showing the logic for a program : Write the psuedocode showing the logic for a program that allows a user to enter 12 numbers and then displays them in the reverse order of their entry

Reviews

Write a Review

Programming Languages Questions & Answers

  How write the program to calculate simple matrix

How to write the program to calculate simple 3x3 spreadsheet containing integers and strings. First, input spreadsheet source values from console.

  Write program with procedure which draws shape

Write down program with procedure which draws a shape of your choice. Your program must then call the procedure 10 times to draw the shape at 10 random locations.

  Create the css for a website

Create a file called lab1.html which contains the HTML of a blog page. Create another filelab1.css which is linked from lab1.html , and which contains all the style formatting of thedocument. These files must match the specification given below.

  Create application to use scrollable control track

Create the Application which permits you to enter amount of a purchase and then display the amount of sales tax on the purchase. Use a scrollable control such as a track bar to adjust the tax rate.

  1 microsoft is developing a new program and they want to

1. microsoft is developing a new program and they want to identify the break-even point.their fixed cost is 72000 while

  Describe logic why it is not enough to show reduction

If we can only show: if x belongs to A, then y does not belongs to B;explain the logic why it is not enough to show A reduction B.IN other words why the theory needs to prove"if and only if"?

  Write an anonymous block that places a substitution variable

Write an anonymous block that places a substitution variable (&) into a local variable of type varchar2. You will need to convert the types and round them to nearest tens unit. For example 84.4555 would be 84.5.

  Design a calculator program that will add subtract multiply

design a calculator program that will add subtract multiply or divide two numbers input by a user.your program

  Explain programming language is machine independent

Explain what does it mean to say that programming language is machine independent? What do you mean by operator precedence? Depending on operator precedence, what values could be related with expression 6 + 2 * 3?

  Write program to operate as point of sale application

Write down program which will operate as the point of sale (POS) application at carpet retailer. Carpet will be sold by square yard. Padding will be sold by square yard.

  Create an abstract representation of a generic animal

Create an abstract representation of a generic Animal that has the at least two polymorphic methods for making a sound and showing the image of the animal.

  Create the program uses two arrays to hold employee names

Create the program which uses two arrays: one to hold employee names and one to hold employee salaries (standard US currency, two decimal points). The program must prompt user to enter employee names.

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