Question

C++ Help. PLEASE include detailed comments and explanations. PLEASE follow the drections exactly. Thank you. Define...

C++ Help. PLEASE include detailed comments and explanations. PLEASE follow the drections exactly. Thank you.

Define a class with the name BankAccount and the following members:

Data Members:

accountBalance: balance held in the account

interestRate: annual interest rate.

accountID: unique 3 digit account number assigned to each BankAccount object. Use a static data member to generate this unique account number for each BankAccount

count: A static data member to track the count of the number of BankAccount objects created.

Member Functions

void withdraw(double amount): function which withdraws an amount from accountBalance

void deposit(double amount): function which deposits an amount to the accountBalance.

void calculateMonthlyInterest( ): function which calculates the monthly interest and adds to accountBalance

void displayAccountInfo( ): function which displays the accountID, accountBalance, interestRate and count of the number of BankAccounts created.

Define the derived classes CheckingAccount and SavingsAccount from BankAccount with the following interest rates:

const double DEFAULT_INTEREST_RATE_CHECKING = 0.04;

const double DEFAULT_INTEREST_RATE_SAVINGS = 0.06;

If the AccountBalance of the CheckingAccount falls below $500 then a fee

of $50 is charged to the account.

const double DEFAULT_FEE_CHECKING = 50.0;

Use the following driver to validate your program:

#include <iostream>

#include <iomanip>

#include "SavingsAccount.h"

#include "CheckingAccount.h"

using namespace std;

int main()

{

     CheckingAccount jackAccount(1000);

     CheckingAccount lisaAccount(450);

     SavingsAccount samirAccount(9300);

     SavingsAccount ritaAccount(32);

     jackAccount.deposit(1000);

     lisaAccount.deposit(2300);

     samirAccount.deposit(800);

     ritaAccount.deposit(500);

     jackAccount.calculateMonthlyInterest();

     lisaAccount.calculateMonthlyInterest();

     samirAccount.calculateMonthlyInterest();

     ritaAccount.calculateMonthlyInterest();

     cout << "***********************************" << endl;

     jackAccount.displayAccountInfo();

     lisaAccount.displayAccountInfo();

     samirAccount.displayAccountInfo();

     ritaAccount.displayAccountInfo();

     cout << "***********************************" << endl << endl;

     jackAccount.withDraw(250);

     lisaAccount.withDraw(350);

     samirAccount.withdraw(120);

     ritaAccount.withdraw(290);

     cout << "********After withdrawals ***************" << endl;

     jackAccount.displayAccountInfo();

     lisaAccount.displayAccountInfo();

     samirAccount.displayAccountInfo();

     ritaAccount.displayAccountInfo();

     cout << "***********************************" << endl << endl;

     system("pause");

     return 0;

}

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Code:

#include <iostream>

using namespace std;

class BankAccount{
public:
const int uid;
BankAccount() : uid(accountID++){
accountBalance = 0.0;
}
  
BankAccount(double balance1) : uid(accountID++){
accountBalance = balance1;
}
  
int get_actNumber() {
return uid;
}
void deposit(double amount) {
accountBalance = accountBalance + amount;
}
void withdraw(double amount) {
accountBalance = accountBalance - amount;
}
double get_balance() {
return accountBalance;
}
int count(){
return uid;
}
  
protected:
double accountBalance;
static int accountID;
};

int BankAccount::accountID = 100;

class SavingsAccount : public BankAccount {
public:
SavingsAccount(double balance)
: BankAccount(balance) {
rate = .06;
}
  
void set_interestRate(double rate) {
rate = rate;
}
  
double get_interestRate() {
return rate;
}
  
void postInterest() {
accountBalance += (accountBalance * rate);
}

void withDraw(double amount) {
if (accountBalance >= amount) {
accountBalance = accountBalance - amount;
} else {
cout << "Insufficient funds. Withdrawl transaction rejected, balance remains the same" << endl;
}
}

void displayAccountInfo() {
cout << "Interest Saving ACCT#:" << get_actNumber() << " Balance: $" << get_balance() << endl;
}

void calculateMonthlyInterest(){
accountBalance = accountBalance + (rate * accountBalance);
}
protected:
double rate;

};

class CheckingAccount : public BankAccount {
private:
int fee;
float minBalance;
float rate;

public:
CheckingAccount(double balance)
: BankAccount(balance)
{
//_number = get_actNumber();
fee = 50;
minBalance = 500;
rate = 0.04;
}
  
void set_interestRate(double rate) {
rate = rate;
}
double get_interestRate() {
return rate;
}
void set_minBalance(double minBal) {
minBalance = minBal;
}
double get_minBalance() {
return minBalance;
}
bool checkMin() {
if (accountBalance >= minBalance)
{
return true;
}
else
return false;
}
void set_fee(double fee1) {
fee = fee1;
}
double get_fee() {
return fee;
}
void postInterest() {
accountBalance += (accountBalance * rate);
}
void withDraw(double amount) {
if (accountBalance < amount) {
cout << "insufficient funds. Withdrawl rejected, does not affect balance." << endl;
}
else {
if (accountBalance - amount >= minBalance) {
accountBalance = accountBalance - amount;
}
else
{
accountBalance -= (amount + fee);
  
}
  
}
}
void displayAccountInfo() {
cout << "Interest Checking ACCT#:" << get_actNumber() << " Balance: $" << get_balance() << endl;
}
void calculateMonthlyInterest(){
accountBalance = accountBalance + (rate * accountBalance);
}
};

int main() {
   CheckingAccount jackAccount(1000);
CheckingAccount lisaAccount(450);
SavingsAccount samirAccount(9300);
SavingsAccount ritaAccount(32);
jackAccount.deposit(1000);
lisaAccount.deposit(2300);
samirAccount.deposit(800);
ritaAccount.deposit(500);
jackAccount.calculateMonthlyInterest();
lisaAccount.calculateMonthlyInterest();
samirAccount.calculateMonthlyInterest();
ritaAccount.calculateMonthlyInterest();
cout << "***********************************" << endl;
jackAccount.displayAccountInfo();
lisaAccount.displayAccountInfo();
samirAccount.displayAccountInfo();
ritaAccount.displayAccountInfo();
cout << "***********************************" << endl << endl;
jackAccount.withDraw(250);
lisaAccount.withDraw(350);
samirAccount.withdraw(120);
ritaAccount.withdraw(290);
cout << "********After withdrawals ***************" << endl;
jackAccount.displayAccountInfo();
lisaAccount.displayAccountInfo();
samirAccount.displayAccountInfo();
ritaAccount.displayAccountInfo();
cout << "***********************************" << endl << endl;
system("pause");
return 0;
}

Output:

***********************************
Interest Checking ACCT#:100 Balance: $2080
Interest Checking ACCT#:101 Balance: $2860
Interest Saving ACCT#:102 Balance: $10706
Interest Saving ACCT#:103 Balance: $563.92
***********************************

********After withdrawals ***************
Interest Checking ACCT#:100 Balance: $1830
Interest Checking ACCT#:101 Balance: $2510
Interest Saving ACCT#:102 Balance: $10586
Interest Saving ACCT#:103 Balance: $273.92
***********************************

Screenshot:

Your Code #include <iostream> 3 using namespace std; 5 class BankAccount 6 public: const int uid; BankAccount) uid(accountID++) accountBalance0.0 10 12 13 14 15 16 17 18 19 20 21 BankAccount(double balance1) : uid(accountID) accountBalance = balance!; int get actNumberO return uid; void deposit(double amount) accountBalance-accountBalance amount 23 24 25 26 27 28 29 30 31 32 void withdraw(double amount) double get_balance) int countOf accountBalanceaccountBalance amount; return accountBalance; return uid; protected: double accountBalance; static int accountID; 34 35 36 37 int BankAccount::accountID 100 38 39 class SavingsAccount: public BankAccount t 40 41 42 43 public: SavingsAccount (double balance) : BankAccount(balance) f rate .06; 45 void set interestRate(double rate) 47 48 rate - rate;

Add a comment
Know the answer?
Add Answer to:
C++ Help. PLEASE include detailed comments and explanations. PLEASE follow the drections exactly. Thank you. Define...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • MAIN OBJECTIVE       Develop a polymorphic banking program using the Account hierarchy created (below). C++ Capture...

    MAIN OBJECTIVE       Develop a polymorphic banking program using the Account hierarchy created (below). C++ Capture an output. polymorphism. Write an application that creates a vector of Account pointers to two SavingsAccount and two CheckingAccountobjects. For each Account in the vector, allow the user to specify an amount of money to withdraw from the Account using member function debit and an amount of money to deposit into the Account using member function credit. As you process each Account, determine its...

  • Introduction Extend the inheritance hierarchy from the previous project by changing the classes to template classes....

    Introduction Extend the inheritance hierarchy from the previous project by changing the classes to template classes. Do not worry about rounding in classes that are instantiated as integer classes, you may just use the default rounding. You will add an additional data member, method, and bank account type that inherits SavingsAc-count ("CD", or certicate of deposit). Deliverables A driver program (driver.cpp) An implementation of Account class (account.h) An implementation of SavingsAccount (savingsaccount.h) An implementation of CheckingAccount (checkingaccount.h) An implementation of...

  • C++ Banks offer various types of accounts, such as savings, checking, certificate of deposits, and money...

    C++ Banks offer various types of accounts, such as savings, checking, certificate of deposits, and money market, to attract customers as well as meet their specific needs. Two of the most commonly used accounts are savings and checking. Each of these accounts has various options. For example, you may have a savings account that requires no minimum balance but has a lower interest rate. Similarly, you may have a checking account that limits the number of checks you may write....

  • I need help modifying this code please ASAP using C++ Here is what I missed on this code below Here are the instruction...

    I need help modifying this code please ASAP using C++ Here is what I missed on this code below Here are the instructions Here is the code Produce correct70 pts O pts Full Marks No Marks results and statisfy requirements view longer Comments 1. Your display amount is not readable 2. I withdraw more than my balance, but I didn't see any error message description Documentations10 pts 0 pts Full Marks No Marks : comment i code and block comment...

  • C++ Design a class bankAccount that defines a bank account as an ADT and implements the...

    C++ Design a class bankAccount that defines a bank account as an ADT and implements the basic properties of a bank account. The program will be an interactive, menu-driven program. a. Each object of the class bankAccount will hold the following information about an account: account holder’s name account number balance interest rate The data members MUST be private. Create an array of the bankAccount class that can hold up to 20 class objects. b. Include the member functions to...

  • (C++) How do I develop a polymorphic banking program using an already existing Bank-Account hierarchy? For each account...

    (C++) How do I develop a polymorphic banking program using an already existing Bank-Account hierarchy? For each account in the vector, allow the user to specify an amount of money to withdraw from the Bank-Account using member function debit and an amount of money to deposit into the Bank-Account using member function credit. As you process each Bank-Account, determine its type. If a Bank-Account is a Savings, calculate the amount of interest owed to the Bank-Account using member function calculateInterest,...

  • c++ help please. Savings accounts: Suppose that the bank offers two types of savings accounts: one...

    c++ help please. Savings accounts: Suppose that the bank offers two types of savings accounts: one that has no minimum balance and a lower interest rate and another that requires a minimum balance but has a higher interest rate (the benefit here being larger growth in this type of account). Checking accounts: Suppose that the bank offers three types of checking accounts: one with a monthly service charge, limited check writing, no minimum balance, and no interest; another with no...

  • Im having trouble with this C++ program. Lab 10/object/test files provided LAB 10 1 //Savings.cpp - displays the account balance at 2 //the end of 1 through 3 years 3 //Created/revised by <your nam...

    Im having trouble with this C++ program. Lab 10/object/test files provided LAB 10 1 //Savings.cpp - displays the account balance at 2 //the end of 1 through 3 years 3 //Created/revised by <your name> on <current date> 4 5 #include <iostream> 6 #include <iomanip> 7 #include <cmath> 8 using namespace std; 9 10 //function prototype 11 double getBalance(int amount, double rate, int y); 12 13 int main() 14 { 15 int deposit = 0; 16 double interestRate = 0.0; 17...

  • I need a detailed pseudocode for this code in C ++. Thank you #include <iostream> #include...

    I need a detailed pseudocode for this code in C ++. Thank you #include <iostream> #include <string> #include <iomanip> using namespace std; struct Drink {    string name;    double cost;    int noOfDrinks; }; void displayMenu(Drink drinks[], int n); int main() {    const int size = 5;       Drink drinks[size] = { {"Cola", 0.65, 2},    {"Root Beer", 0.70, 1},    {"Grape Soda", 0.75, 5},    {"Lemon-Lime", 0.85, 20},    {"Water", 0.90, 20} };    cout <<...

  • Please show it in C++. Thank you! Problem Definition Create an inheritance hierarchy containing base class...

    Please show it in C++. Thank you! Problem Definition Create an inheritance hierarchy containing base class Account and derived class Savings-Account. Base class Account should include one data member of type double to represent the account balance. The class should provide a constructor that receives an initial baiance and uses it to initialize the data member. The class should provide three member functions. Member function credit should add an amount to the current balance. Member function debit should withdraw money...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT