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

  Design program which models the worms behavior

Design a program which models the worms behavior in the following scenario: A worm is moving toward an apple. Each time it moves, the worm cuts the distance between itself and the apple.

  How you take care of these missed values

For the assignment, assume that the sensed data are be generated randomly either by a random number generator in your program or read a triplet every time from a file which is pre@generated).

  Write function which takes string and returns vowels

Write a function which takes as a parameter an string and returns vowels (a, e, i, o, u). The function prototype should look like:

  Create shell script to enter length and width of rectangle

Network client needs you create the shell script which permits the user to enter length and width of rectangle. Perimeter of rectangle is then computed and printed to computer screen.

  Write program to reads student-s name with test scores

Write down a program which reads student's name together with his or her test scores. Program must calculate the average test score for each student and allot the suitable grade.

  Pseudocode for a program to solve mathematical problem

Pseudocode for a program to solve the following problem. A student borrows $3,000 at an interest rate 2% per month on the unpaid balance.

  Applying constraints in program

You will require to set up constants in program for given: number of square feet per square yard.

  Write a program that takes a single directory as an argument

Write a program that takes a single directory as an argument, and iterates through all the normal files in the directory, and concatenate them to standard out.

  Write program to accept data for each student

Write a program that accepts data for each student in the school - Student ID, classroom number, and score on the achievement test. Design a program that lists the total points scored for each of the 30 classrooms.

  Develop unix shell script to input number of hours

Develop a Unix shell script to input number of hours worked and pay rate and calculate the total pay, then the social security amount (assume 5%), then the net pay.

  User defined function to calculate average of three scores

A user defined function that will calculate and display the average of the 3 scores that remain after dropping the highest and lowest scores the performer received.

  What criterion is being used to determine best estimates

What we would like to do is create similar tables in an .rtf file that produces the same statistics for any numerical value against each level of a know classification/factor from any data set we wish to inspect.

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