Create a class called bank account

Assignment Help C/C++ Programming
Reference no: EM13763646

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 Negative Amount Exception 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: EM13763646

Questions Cloud

Contract for a nonprofit organization : The following scenario addresses potential contractual disputes involving a contract for a nonprofit organization
Influence long-run profitability of the firms : Identify one real-life example of a market structure in your local city and relate your example to each of the characteristics of the market and describe how high entry barriers into a market will influence long-run profitability of the firms.
Cost of goods manufactured statement : Denny Corporation, a manufacturing company, produces a single product.  The following information has been taken from the company's production, sales, and cost records for the year just completed:
What legal concerns are raised by these issues : Internet domain names are linked to trademark issues. Technology makes it easy to copy and distribute music and movies without paying royalties. Business conducted on the internet raise security and privacy issues. What legal concerns are raised..
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
Potential reduction in interest costs : Discuss why Busch may desire to have an audit, ignoring the potential reduction in interest costs. Explain how a strategic understanding of the client's business may increase the value of the audit service.
Influences the demand curve for indoor grill products : How do people's budget, income, and substitution effects fit - How do you think influences the demand curve for indoor grill products?
Disadvantages of utilizing the weighted average cost : Your presentation should address the following questions and offer a final recommendation to Coogly. Make sure you support your answers and clearly explain the advantages and disadvantages of utilizing the weighted average cost of capital methodol..
Explain why this type of fallacy is a bad way of reasoning : In this assignment, you will compose three original examples of informal fallacy arguments. Identify and define the fallacy. For example, appeal to tradition, false dichotomy, etc. Explain why this type of fallacy is a bad way of reasoning

Reviews

Write a Review

C/C++ Programming Questions & Answers

  What does the following display

Given the subsequent array definition: double rainfall[] = {1.4, 1.2, 3.4, 1.8, 1.6}; what does the following display?

  Display the largest and smallest numbers entered

Design a java program with a loop that lets the user enter a series of numbers - After all the numbers have been entered, the program should display the largest and smallest numbers entered.

  Implement a class to represent a matrix

Implement a class to represent a matrix. While doing this exercise, you are allowed only to use C++ primitive types and arrays. You may not use STL in your Matrix definition. You must use dynamic memory.

  Accept positive and negative numbers in its input sequence

the program must accept positive and negative numbers in its input sequence, and ?nd the largest and smallestof the numbers entered whether they are all positive, all negative, or a combination of both positive and negative.

  Composite data types (arrays & records)

Composite data types (arrays & records) can be a problem when they are passed as parameters or returned by functions. Why?

  Write a program to determine how long (sec.)

Using the v 2  form of drag, write a program to determine how long (sec.) and how far (m) a 150 gram ball whose radius is 3.5cm would fall before it reached 75% of its terminal velocity. Assume ball falls in air whose density is 1.21 kg/m 3 , has a d..

  The big picturethis assignment consists of two separate

the big picturethis assignment consists of two separate programming tasks.1. you will create a linked list module that

  Temperature conversions

Temperature Conversions. The following problems generate temperature- conversion tables. Use following equations that give relationships between temperatures in degrees Fahrenheit(Tf), degree Celsius(Tc), degrees Kelvin(Tk), and degrees Rankin(Tr);

  Complexity of quick sort algorithm

Write a c program to experimentally compare the O() complexities of the provided quick sort algorithm

  Insert the missing code in the c program

You are to insert the missing code in the C program given for combinational equivalence checking. This program will interface with the CUDD package and will parse netlist files in ISCAS85 circuit format. Next, BDDs will be created for each circuit an..

  Define a structure to store roll no

Define a structure to store roll no, name and marks of a student. Using the structure of above write a ‘C’ program to create a file “student.dat”. There must be one record for every student in the file. Accept the data from the user.

  The westfield carpet company has asked you to write an

the westfield carpet company has asked you to write an application that calculates the price of carpeting for

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