Question

In: Computer Science

Building a console application in C++ and add features for specific types of accounts that exist...

Building a console application in C++ and add features for specific types of accounts that exist in a real Bank. Savings accounts, for instance, earn interest on the money they hold. Checking accounts, on the other hand, charge a fee per transaction (i.e., credit or debit).

a. Create an Inheritance hierarchy using base class Account and derived classes Savings-Account and CheckingAccount.

b. Derived class SavingsAccount should inherit the functionality of an Account, but also include a data member indicating the interest rate (percentage) assigned to the Account. SavingsAccount’s constructor should receive the initial balance, as well as an initial value for the SavingsAccount’s interest rate. SavingsAccount should provide a public member function CalculateInterest that returns a double indicating the amount of interest earned by an account. Member function CalculateInterest should determine this amount by multiplying the interest rate by the account balance. [Note: SavingsAccount should inherit member functions credit and debit as is without redefining them.]

c. Derived class Checking Account should inherit from base class Account and include an additional data member that represents the fee charged per transaction. Checking Account’s    constructor should receive the initial balance, as well as a parameter indicating a fee amount. Class Checking Account should redefine member function debit so that it will subtract the fee from the account balance whenever the transaction is performed successfully. Checking Account’s debit and check balance functions should invoke the base-class Account version to perform the updates to an account balance. Checking Account’s debit function should charge a fee only if money is actually withdrawn (i.e., the debit amount does not exceed the account balance).

[Hint: Define Account’s debit function so that it returns a bool indicating whether money was withdrawn. Then use the return value to determine whether a fee should be charged.]

d. After defining the classes in this hierarchy, write a program that creates objects of each class and tests their member functions. Add interest to the Savings Account object by first invoking its calculate Interest function, then passing the returned interest amount to the object’s credit function.

Can someone help with this please? Include comments lines

Solutions

Expert Solution

Given below is the required C++ program-

#include <iostream>

using namespace std;

class account

{

public:

double bal; // variables defined

void credit(int amt) // debit function defined

{

bal=bal-amt;

}

void debit(int amt) // credit function defined

{

bal=bal+amt;

}

};

class saving_account : public account

{

public:

int irate;

saving_account(double r,int b)

{

irate=r;

bal=b;

}

double calculateinterest() // calculate interest defined

{

return bal*(irate/100.0);

}

};

class checking_account : public account

{

public:

int irate;

int fees;

checking_account(double r,int b,int fee)

{

irate=r;

bal=b;

fees=fee;

}

double calculateinterest() // calculate interest defined

{

return bal*(irate/100.0);

}

void credit(int amt)

{

bal=(bal-amt)-fees;

};

void debit(int amt)

{

bal=(bal+amt)-fees;

}

};

int main()

{

saving_account obj(10.0,23400); // object defined

checking_account obj1(10.0,24000,); // object defined

cout<<"Interest calculated for savings"<<obj.calculateinterest()<<endl;

cout<<"Interest calculated for checking"<<obj1.calculateinterest()<<endl;

}

If this answer is helpful please give it a thumbs up......


Related Solutions

Language: C# Create a new Console Application. Your Application should ask the user to enter their...
Language: C# Create a new Console Application. Your Application should ask the user to enter their name and their salary. Your application should calculate how much they have to pay in taxes each year and output each amount as well as their net salary (the amount they bring home after taxes are paid!). The only taxes that we will consider for this Application are Federal and FICA. Your Application needs to validate all numeric input that is entered to make...
C# Create a console application that prompts the user to enter a regular expression, and then...
C# Create a console application that prompts the user to enter a regular expression, and then prompts the user to enter some input and compare the two for a match until the user presses Esc: The default regular expression checks for at least one digit. Enter a regular expression (or press ENTER to use the default): ^[a- z]+$ Enter some input: apples apples matches ^[a-z]+$? True Press ESC to end or any key to try again. Enter a regular expression...
with C# create a console application project that outputs the number of bytes in memory that...
with C# create a console application project that outputs the number of bytes in memory that each of the following number types use, and the minimum and maximum values they can have: sbyte, byte, short, ushort, int, uint, long, ulong, float, double, and decimal. Try formatting the values into a nice-looking table! More Information: You can always read the documentation, available at https://docs.microsoft.com/en-us/dotnet/standard/base-types/composite-formatting for Composite Formatting to learn how to align text in a console application. Your output should look...
Loops Write a simple C/C++ console application that will calculate the equivalent series or parallel resistance....
Loops Write a simple C/C++ console application that will calculate the equivalent series or parallel resistance. Upon execution the program will request ether 1 Series or 2 Parallel then the number of resisters. The program will then request each resistor value. Upon entering the last resistor the program will print out the equivalent resistance. The program will ask if another run is requested otherwise it will exit.
C# & ASP.NET Create a console application that prompts the user to enter a regular expression,...
C# & ASP.NET Create a console application that prompts the user to enter a regular expression, and then prompts the user to enter some input and compare the two for a match until the user presses Esc: The default regular expression checks for at least one digit. Enter a regular expression (or press ENTER to use the default): ^[a- z]+$ Enter some input: apples apples matches ^[a-z]+$? True Press ESC to end or any key to try again. Enter a...
write a c# console application app that reads all the services in the task manager and...
write a c# console application app that reads all the services in the task manager and automatically saves what was read in a Notepad txt file.  Please make sure that this program runs, also add some comments
c# Create a console application that protects an XML file, such as the following example. Note...
c# Create a console application that protects an XML file, such as the following example. Note that the customer's credit card number and password are currently stored in clear text. The credit card must be encrypted so that it can be decrypted and used later, and the password must be salted and hashed: <?xml version="1.0" encoding="utf-8" ?> <customers> <customer> <name>Bob Smith</name> <creditcard>1234-5678-9012-3456</creditcard> <password>Pa$$w0rd</password> </customer> </customers>
C# Create a console application project that outputs the number of bytes in memory that each...
C# Create a console application project that outputs the number of bytes in memory that each of the following number types use, and the minimum and maximum values they can have: sbyte, byte, short, ushort, int, uint, long, ulong, float, double, and decimal. Try formatting the values into a nice-looking table! Your output should look something like this: | Type | Bytes of Memory | Min | Max |
programming language is c#. Create a method that prompts a user of your console application to...
programming language is c#. Create a method that prompts a user of your console application to input the information for a student: static void GetStudentInfo() { Console.WriteLine("Enter the student's first name: "); string firstName = Console.ReadLine(); Console.WriteLine("Enter the student's last name"); string lastName = Console.ReadLine(); // Code to finish getting the rest of the student data ..... } static void PrintStudentDetails(string first, string last, string birthday) { Console.WriteLine("{0} {1} was born on: {2}", first, last, birthday); } 1. Using the...
Develop a C# console application that will implement one method that will return an integer value,...
Develop a C# console application that will implement one method that will return an integer value, one void method that will calculate an average, and one void overload for the calculate method that will compute a total. Please read the requirements below carefully. In Main: You will need four variables: an integer value to hold a random value, a double value to hold an average, a double value to hold a total, and a double value to hold an input...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT