Question

TIC PEO. Design a generic class to hold the following information about a bank account! Balance Number of deposits this month
1 Chapter 15 Inheritance, Polymorphism, and Virtual Functions If the balance of a savings account falls below $25, it becomes

the programing language is C++
0 0
Add a comment Improve this question Transcribed image text
Answer #1

Program:

BankAccount.h:

#ifndef BANKACCOUNT_H

#define BANKACCOUNT_H

class BankAccount

{

       protected:

              double balance;

              int NumberOfDeposits;

              int NumberOfWithdrawls;

              double AnnualInterestRate;

              double MonthlyServiceCharges;

              double TotalDepositAmount;

              double TotalWithdrawAmount;

             

       public:

              BankAccount(double Bal, double InterestRate)

              {

                     balance = Bal;

                     AnnualInterestRate = InterestRate;

                     NumberOfDeposits = 0;

                     NumberOfWithdrawls = 0;

                     MonthlyServiceCharges = 0;

                     TotalDepositAmount = 0;

                     TotalWithdrawAmount = 0;

              }

              virtual void deposit(double Bal)

              {

                     balance += Bal;

                     TotalDepositAmount += Bal;

                     NumberOfDeposits++;

              }

              virtual void withdraw(double Bal)

              {

                     balance -= Bal;

                     TotalWithdrawAmount += Bal;

                     NumberOfWithdrawls++;

              }

              virtual void calcint()

              {

                     double MonthlyInterestRate = (AnnualInterestRate / 12);

                     double MonthlyInterest = balance * MonthlyInterestRate;

                     balance += MonthlyInterest;

              }

              virtual void monthlyProc()

              {

                     balance -= MonthlyServiceCharges;

                     calcint();

                     NumberOfDeposits = 0;

                     NumberOfWithdrawls = 0;

                     MonthlyServiceCharges = 0;

              }

              double getBalance()

              {

                     return balance;

              }

              double getMonthlyServiceCharges()

              {

                     return MonthlyServiceCharges;

              }

              double getTotalDepositAmount()

              {

                     return TotalDepositAmount;

              }

              double getTotalWithdrawAmount()

              {

                     return TotalWithdrawAmount;

              }

};

#endif

Account.cpp:

#include<iostream>

#include<stdbool.h>

#include "BankAccount.h"

using namespace std;

class SavingAccount : public BankAccount

{

private:

       bool status;

public:

       SavingAccount(double Bal, double Intrate) : BankAccount(Bal, Intrate)

       {

       }

       bool checkStatus()

       {

              if (BankAccount::balance < 25.0)

                     return false;

              else

                     return true;

       }

       void withdraw(double Bal)

       {

              if (checkStatus())

              {

                     BankAccount::withdraw(Bal);

              }

       }

       void deposit(double Bal)

       {

              if (checkStatus() == false)

              {

                     if (BankAccount::balance + Bal > 25)

                           status = true;

              }

              BankAccount::deposit(Bal);

       }

       void monthlyProc()

       {

              if (BankAccount::NumberOfWithdrawls > 4)

              {

                     BankAccount::MonthlyServiceCharges += 1;

                     BankAccount::balance -= 1;

                     if (BankAccount::balance < 25)

                           status = false;

              }

       }

};

class CheckingAccount :public BankAccount

{

public:

       CheckingAccount(double Bal, double Intrate) : BankAccount(Bal, Intrate)

       {

       }

       void withdraw(double Bal)

       {

              if (balance - Bal < 0)

              {

                     MonthlyServiceCharges += 15;

                     balance -= 15;

              }

              else

                     BankAccount::withdraw(Bal);

       }

       void monthlyProc()

       {

              MonthlyServiceCharges += 5;

              MonthlyServiceCharges += 0.10*NumberOfWithdrawls;            

       }

};

int main()

{

       double deposit, withdrawl, StartBalance;

       BankAccount *obj = new SavingAccount(300, 12);

       cout << "Please enter the money to deposit into the savings account: ";

       cin >> deposit;

       StartBalance = obj->getBalance();

       obj->deposit(deposit);

       cout << "Please enter the money to withdraw from the savings account: ";

       cin >> withdrawl;

       obj->withdraw(withdrawl);

       cout << "Start balance of the month is " << StartBalance << endl;

       cout << "Total amount of deposit is " << obj->getTotalDepositAmount() << endl;

       cout << "Total amount of withdrawl is " << obj->getTotalWithdrawAmount() << endl;

       cout << "Monthly service charge is " << obj->getMonthlyServiceCharges() << endl;

       cout << "Ending balance of the month is " << obj->getBalance() << endl<<endl;

      

       BankAccount *obj1 = new CheckingAccount(100, 10);

       cout << "Please enter the money to deposit into the checking account: ";

       cin >> deposit;     

       StartBalance = obj1->getBalance();

       obj1->deposit(deposit);

       cout << "Please enter the money to withdraw from the savings account: ";

       cin >> withdrawl;

       obj1->withdraw(withdrawl);

       cout << "Start balance of the month is " << StartBalance << endl;

       cout << "Total amount of deposit is " << obj1->getTotalDepositAmount() << endl;

       cout << "Total amount of withdrawl is " << obj1->getTotalWithdrawAmount() << endl;

       cout << "Monthly service charge is " << obj1->getMonthlyServiceCharges() << endl;

       cout << "Ending balance of the month is " << obj1->getBalance() << endl;

      

       return 0;

}

Sample output:

clusers dileep.dola\documents\visual studio 2015\Projects ConsoleApplication1\Debug Consol.. Please enter the money to deposi

Add a comment
Know the answer?
Add Answer to:
the programing language is C++ TIC PEO. Design a generic class to hold the following information...
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
  • BankAccount and SavingsAccount Classes (JAVA)

    Must be in GUI interfaceDesign an abstract class namedBankAccountto hold the following data for a bankaccount:* Balance* Number of deposits this month* Number of withdrawals (this month)* Annual interest rate* Monthly service chargesThe class should have the following methods:Constructor: The constructor should accept arguments for the balance and annual interest rate.deposit: A method that accepts an argument for the amount of the deposit. The methods should add the argument to the account balance. It should also increment thevariable holding the...

  • pls write psuedocode write UML CODE ALSO example 3 files 1 for abstract 1 for bank...

    pls write psuedocode write UML CODE ALSO example 3 files 1 for abstract 1 for bank account and 1 for savings accounts due in 12 hours Lab Assignment 4a Due: June 13th by 9:00 pm Complete the following Programming Assignment. Use good programming style and all the concepts previously covered. Submit the java files electronically through Canvas by the above due date in 1 Zip file Lab4.Zip. (This is from the chapter on Inheritance.) 9. BankAccount and SavingsAccount Classes Design...

  • Design and implement the following 3 classes with the exact fields and methods (these names and c...

    Design and implement the following 3 classes with the exact fields and methods (these names and caps exactly): 1. An abstract class named BankAccount (java file called BankAccount.java) Description Filed/Method Balance NumberDeposits NumberWithdrawals AnnualInterestRate MonthlyServiceCharge BankAccount SetHonthlyServiceCharges A method that accepts the monthly service charges as an argument and set the field value GetBalance GetNum berDeposits GetNum berWithdrawals GetAnnualinterestRate GetMonthlyServiceCharge A method that returns the monthly service charge Deposit field for the bank account balance A field for the number...

  • Design a bank account class named Account that has the following private member variables:

    Need help please!.. C++ programDesign a bank account class named Account that has the following private member variables: accountNumber of type int ownerName of type string balance of type double transactionHistory of type pointer to Transaction structure (structure is defined below) numberTransactions of type int totalNetDeposits of type static double.The totalNetDeposits is the cumulative sum of all deposits (at account creation and at deposits) minus the cumulative sum of all withdrawals. numberAccounts of type static intand the following public member...

  • solve this JAVA problem in NETBEANS Problem #12 in page 400 of your text (6th edition): SavingsAccount Class. Design a SavingsAccount class that stores a savings account's annual interest rate...

    solve this JAVA problem in NETBEANS Problem #12 in page 400 of your text (6th edition): SavingsAccount Class. Design a SavingsAccount class that stores a savings account's annual interest rate and balance. The class constructor should accept the amount of the savings account's starting balance. The class should also have methods for subtracting the amount of a withdrawal, adding the amount of a deposit, and adding the amount of monthly twelve. To add the monthly interest rate to the balance,...

  • please rewrite this code as Pseudo-Code,.. basically rewrite the code but in english language , Thank...

    please rewrite this code as Pseudo-Code,.. basically rewrite the code but in english language , Thank you so much! public abstract class BankAccount {    //declare the required class variables    private double balance;    private int num_deposits;    private int num_withdraws;    private double annualInterest;    private double serviceCharges;       //constructor that takes two arguments    // one is to initialize the balance and other    // to initialize the annual interest rate       public BankAccount(double balance,...

  • C++ Simple code please Thank you in advance B. Write a C++ program as per the...

    C++ Simple code please Thank you in advance B. Write a C++ program as per the following specifications: a. Define the class BankAccount to store a bank customer's account number and balance. Suppose that account number is of type int, and balance is of type double. Your class should, at least, provide the following operations: set the account number, retrieve the account number, retrieve the balance, deposit and withdraw money, and print account information. Add appropriate constructors. b. Every bank...

  • This is in C++ (using IDE Visual Studio). I am seeking assistance ASAP. Please include a...

    This is in C++ (using IDE Visual Studio). I am seeking assistance ASAP. Please include a static member in the class to automatically assign account numbers (used to process up to 10 accounts) and have the user include their first and last name. Thank you! 13. a. Define the class bankAccount to store a bank customer's account number and balance. Suppose that account number is of type int, and balance is of type double. Your class should, at least, provide...

  • PYTHON PROGRAMMING LANGUAGE Design a class named Savings Account that contains: A private int data field...

    PYTHON PROGRAMMING LANGUAGE Design a class named Savings Account that contains: A private int data field named id for the savings account. A private float data field named balance for the savings account. A private float data field named annuallnterestRate that stores the current interest rate. A_init_ that creates an account with the specified id (default 0), initial balance (default 100), and annual interest rate (default 0). . The accessor and mutator methods for id, balance, and annuallnterestRate. A method...

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