bartleby

Videos

Textbook Question
Book Icon
Chapter 15, Problem 7PP

Banks have many different types of accounts, often with different rules for fees associated with transactions such as withdrawals. Customers are allowed to transfer funds between accounts incurring the appropriate fees associated with withdrawal of funds from one account.

Write a program with a base class for a bank account and two derived classes (as described below) representing accounts with different rules for withdrawing funds. Also write a function that transfers funds from one account (of any type) to another. A transfer is a withdrawal from one account and a deposit into the other. Since the transfer can be done at any time with any type of account, the withdraw function in the classes must be virtual. Write a main program that creates three accounts (one from each class) and tests the transfer function.

For the classes, create a base class called BankAccount that has the name of the owner of the account (a string) and the balance in the account (double) as data members. Include member functions deposit and withdraw (each with a double for the amount as an argument) and accessor functions getName and getBalance. Deposit will add the amount to the balance (assuming the amount is nonnegative) and withdraw will subtract the amount from the balance (assuming the amount is nonnegative and less than or equal to the balance). Also create a class called MoneyMarketAccount that is derived from BankAccount. In a MoneyMarketAccount the user gets two free withdrawals in a given period of time (don’t worry about the time for this problem). After the free withdrawals have been used, a withdrawal fee of $1.50 is deducted from the balance per withdrawal. Hence, the class must have a data member to keep track of the number of withdrawals. It also must override the withdraw definition. Finally, create a CDAccount class (to model a Certificate of Deposit) derived from BankAccount that in addition to having the name and balance also has an interest rate. CDs incur penalties for early withdrawal of funds. Assume that a withdrawal of funds (any amount) incurs a penalty of 25% of the annual interest earned on the account. Assume the amount withdrawn plus the penalty are deducted from the account balance. Again, the withdraw function must override the one in the base class. For all three classes, the withdraw function should return an integer indicating the status (either ok or insufficient funds for the withdrawal to take place). For the purposes of this exercise, do not worry about other functions and properties of these accounts (such as when and how interest is paid).

Blurred answer
Students have asked these similar questions
Write the definitions of the member functions of the class calendarType (designed in Programming Exercise 9) to implement the operations of the class calendarType. Write a test program to print the calendar for either a particular month or a particular year. For example, the calendar for September 2019 is: (check the picture)This is exercise 9: Using the classes extDateType (Programming Exercise 8) and dayType (Chapter 10, Programming Exercise 5), design the class calendarType so that, given the month and the year, we can print the calendar for that month. To print a monthly calendar, you must know the first day of the month and the number of days in that month. Thus, you must store the first day of the month, which is of the form dayType, and the month and the year of the calendar. Clearly, the month and the year can be stored in an object of the form extDateType by setting the day component of the date to 1 and the month and year as specified by the user. Thus, the class…
Example 10-10 defined a class personType to store the name of a person. The member functions that we included merely print the name and set the name of a person. Redefine the class personType so that, in addition to what the existing class does, you can: Set the first name only. Set the last name only. Store and set the middle name. Check whether a given first name is the same as the first name of this person. Check whether a given last name is the same as the last name of this person.
In this task, we’re going to be simulating an email message. ●Create a class definition for an Email.The initialiser takes in two arguments and stores them as instance-level variables:○from_address - the sender’s email address.○subject_line - the subject of the email.○email_contents-the content of the email.●In addition,the initialiser will create two more instance-level variables with defaultvalues:○has_been_read - initialised to False.○is_spam - initialised to False.●Create a function in this class called mark_as_read which should change has_been_read to true.●Create a function in this class called mark_as_spam which should change is_spam to true.●Create another class called "Inbox" to store all emails (note that you can have a list of objects). The initaliser doesn’t take any arguments, and only initialises an empty list. This list is where all of your Email objects will be stored.●Within the Inbox class, create the following methods:○add_email (self, from_address, subject_line,…

Chapter 15 Solutions

Problem Solving with C++, Student Value Edition plus MyProgrammingLab with Pearson eText -- Access Card Package (9th Edition)

Additional Engineering Textbook Solutions

Find more solutions based on key concepts
Design a For loop that calculates the total of the following series of numbers: 130+229+328+...+301

Starting Out with Programming Logic and Design (5th Edition) (What's New in Computer Science)

(Order three cities) Write a program that prompts the user to enter three cities and displays them in ascending...

Introduction to Java Programming and Data Structures, Comprehensive Version (11th Edition)

Find the error in the following class: public class MyClass { private int x; private double y; public void MyCl...

Starting Out with Java: From Control Structures through Objects (6th Edition)

Find the error in the following class: public class TwoValues { private int x, y; public TwoValues() { x = 0; }...

Starting Out with Java: From Control Structures through Data Structures (3rd Edition)

Knowledge Booster
Background pattern image
Computer Science
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
SEE MORE QUESTIONS
Recommended textbooks for you
Text book image
C++ for Engineers and Scientists
Computer Science
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Course Technology Ptr
Text book image
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning
Call By Value & Call By Reference in C; Author: Neso Academy;https://www.youtube.com/watch?v=HEiPxjVR8CU;License: Standard YouTube License, CC-BY