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

  Code the next version of the cp1200 catering calculator

You are to plan and then code the next version of the CP1200 catering calculator, as described in the following information and sample output

  Write program in vb dot net for mortgage payment amount

Write down the program in VB.Net (not Web based) by using the loan amount of $200,000 with the interest rate of 5.75% and 30 year term.

  Write down program which permits to play tic tac toe game

Write down the program which permits 2 players to play tic tac toe game. Program should contain class tictactoe to implement tictactoe object.

  Create prototype of function which returns integer value

Develop the C++ function which needs one integer parameter and returns the integer value. Function will double the value passed to it and return doubled value.

  Create a logical expression

Create a logical expression that corresponds to the following statement - Complete the truth table for the expression created.

  Programming concepts

The assignment problem is straightforward. All necessary details have been supplied. The solution of the problem will be straight line code which will use the programming concepts and strategies covered in Workshops 1-3. The subgoals are:

  Display policy data after revisions have made

The day is not correct for the month (that is, between 1 and 31 for January, 1 and 29 for February, and so on), then set the month, day, and year to 0. Display the policy data after any revisions have been made.

  Copies the content of one file into another file

write a c program that copies the contents of one file to a destination file.

  Write code using while loop for data validation

Write code or pseudo code using while loops to do Data Validation for following user prompts:input positive # input negative # input number between 1 and 100, inclusive.

  Tools assist novice programmer to generate code

Structured English and gave to a novice programmer who used it to create code? If not, what other tools could be used to assist the novice programmer to generate code?

  Write program which reads in side of a square

Write a program which reads in side of a square and then prints that square out of asterisks. Program must work for hollow squares of all side sizes between 1 and 20.

  Write a function calculating the length of the hypotenuse

(Hypotenuse Calculations) Write a function calculating the length of the hypotenuse of a right triangle (have two sides already). Determine the length of the hypotenuse for each of the given triangles.

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