Question

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 customers account number and balance. Suppose that account number is of

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

Note: Could you plz go through this code and let me know if u need any changes in this.Thank You
_________________

#include <iostream>
using namespace std;
// Creating base class Account
class bankAccount
{
private:
   static int accNo;
   int accountNumber;
// Declaring variables
double balance;
public:
   bankAccount()
   {
      
   }
// parameterized constructor
bankAccount(double balance)
{
this->balance = balance;
  
this->accountNumber=accNo;
accNo++;
}
// Function declarations
void setAccNo(int accNo);
int getAccNo();
void deposit(double amount);
void withdraw(double amount);
double getBalance();
void displayInfo()
{
   cout<<"Account Number :"<<getAccNo()<<endl;
   cout<<"Balance :$"<<getBalance()<<endl;
}
  
};
int bankAccount::accNo=1000;

/* Function implementation
* which adds money to the current balance
*/
void bankAccount::deposit(double amount)
{
this->balance = balance + amount;
}
/* Function implementation
* which subtract money to the current balance
*/
void bankAccount::withdraw(double amount)
{
if (amount > balance)
{
cout << "Balance is low" << endl;
}
else
{
this->balance = balance - amount;
}
}
/* Function implementation
* which gets current balance
*/
double bankAccount::getBalance()
{
return this->balance;
}

int bankAccount::getAccNo()
{
   return accountNumber;
}

// Creating the sub class derived from Base class Account
class SavingsAccount : public bankAccount
{
private:
// Declaring variables
double rate;
double accountNum;
public:
// parameterized constructor
SavingsAccount(double balance, double rate)
: bankAccount(balance)
{
this->rate = rate;
this->accountNum=getAccNo();
}
// Function declarations
double calculateInterest();
void setInterestRate(double rate);
double getInterestRate();
void withdraw(double amount);
void displayInfo();
};
/* Function implementation
* which calculates the interest amount
*/
double SavingsAccount::calculateInterest()
{
return getBalance() * (rate / 100);
}

void SavingsAccount::setInterestRate(double rate)
{
   this->rate=rate;
}
double SavingsAccount::getInterestRate()
{
   return rate;
}
/* Function implementation
* which subtract money to the current balance
*/
void SavingsAccount::withdraw(double amount)
{
if (amount > getBalance())
{
cout << "Balance is low" << endl;
}
else
{
withdraw(amount);
}
}
void SavingsAccount::displayInfo()
{
   cout<<"Account Number :"<<getAccNo()<<endl;
   cout<<"Balance :$"<<getBalance()<<endl;
}
// Creating a Checking Account class derivied from Account class
class CheckingAccount : public bankAccount
{
private:
double feePerTx;
double minBal;
double accountNum;
public:
// parameterized constructor
CheckingAccount(double balance)
: bankAccount(balance)
{
this->feePerTx=5;
this->minBal=500;
this->accountNum=getAccNo();
}
// Function declarations
void deposit(double amount);
void withdraw(double amount);
double getMinBalance();
void setMinBalance(double minBal);
double getServiceCharges();
void setServiceCharges(double sCharges);
void displayInfo();
};

/* Function implementation
* which adds money to the current balance
*/
void CheckingAccount::deposit(double amount)
{
bankAccount::deposit(amount);
}
/* Function implementation
* which subtract money to the current balance
*/
void CheckingAccount::withdraw(double amount)
{

if (amount > getBalance()-minBal)
{
withdraw(amount+feePerTx);
  
}
else
{
bankAccount::withdraw(amount);
  
}
}
void CheckingAccount::setMinBalance(double minBal)
{
   this->minBal=minBal;
}

double CheckingAccount::getMinBalance()
{
   return minBal;
}

void CheckingAccount::setServiceCharges(double sCharges)
{
   this->feePerTx=sCharges;
}
double CheckingAccount::getServiceCharges()
{
   return feePerTx;
}
void CheckingAccount::displayInfo()
{
   cout<<"Account Number :"<<getAccNo()<<endl;
   cout<<"Balance :$"<<getBalance()<<endl;
}
int main()
{
   const int size=10;

   CheckingAccount c1(5000);
   CheckingAccount c2(7000);
   CheckingAccount c3(8000);
   CheckingAccount c4(9000);
   CheckingAccount c5(10000);
  
   SavingsAccount s1(5000,5.5);
   SavingsAccount s2(6000,6.5);
       SavingsAccount s3(7000,4.5);
           SavingsAccount s4(8000,3.5);
               SavingsAccount s5(9000,3.5);  
              
               //Creating an array of Student pointers
bankAccount* arr[size] = { &c1,&c2,&c3,&c4,&c5,&s1,&s2,&s3,&s4,&s5};

              
               for(int i=0;i<10;i++)
               {
                   cout<<"Account#"<<i+1<<" Info :"<<endl;
                   arr[i]->displayInfo();
                   cout<<"------------------------"<<endl;
               }
              
  
   return 0;
}

________________________

Output:

_______________Thank You

Add a comment
Know the answer?
Add Answer to:
This is in C++ (using IDE Visual Studio). I am seeking assistance ASAP. Please include a...
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
  • 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...

  • 14 b. Every bank offers a checking account. Derive the class checkingAccount from the class bankAccount...

    14 b. Every bank offers a checking account. Derive the class checkingAccount from the class bankAccount (designed in part (a)). This class inherits members to store the account number and the balance from the base class. A customer with a checking account typically receives interest, maintains a minimum balance, and pays service charges if the balance falls below the minimum balance. Add member variables to store this additional information. In addition to the operations inherited from the base class, this...

  • Q3

    A)Define the class bankAccount to store a bank customer's account number and balance .Suppose that account number is of type int m and balance is of type double . Your class should at least , provide the account number m retrive the balance , depositand withdraw money , and print account information. Add appropriate constructors.B) Every bank offers a checking account . Drive the class checkingAccount from the class bankAccount( design in part (a).This class inherits member to store theaccount...

  • 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...

  • In C++ Write a program that contains a BankAccount class. The BankAccount class should store the...

    In C++ Write a program that contains a BankAccount class. The BankAccount class should store the following attributes: account name account balance Make sure you use the correct access modifiers for the variables. Write get/set methods for all attributes. Write a constructor that takes two parameters. Write a default constructor. Write a method called Deposit(double) that adds the passed in amount to the balance. Write a method called Withdraw(double) that subtracts the passed in amount from the balance. Do not...

  • c++ please    Define the class bankAccount to implement the basic properties of a bank account....

    c++ please    Define the class bankAccount to implement the basic properties of a bank account. An object of this class should store the following data: Account holder’s name (string), account number (int), account type (string, checking/saving), balance (double), and interest rate (double). (Store interest rate as a decimal number.) Add appropriate member func- tions to manipulate an object. Use a static member in the class to automatically assign account numbers. Also declare an array of 10 compo- nents of...

  • 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...

  • Textbook help its not in textbook solutions from the textbook C++ Programming 7th edition Malik,D.S Chapter...

    Textbook help its not in textbook solutions from the textbook C++ Programming 7th edition Malik,D.S Chapter 12 programming exercise 5 Banks offer various types of accounts, such as savings, checking, certificateof deposits, and money market, to attract customers as well as meet their specific needs. Two of the most commonly used accounts are savings andchecking. Each of these accounts has various options. For example, you mayhave a savings account that requires no minimum balance but has a lower interest rate....

  • In this, you will create a bank account management system according to the following specifications: BankAccount...

    In this, you will create a bank account management system according to the following specifications: BankAccount Abstract Class contains the following constructors and functions: BankAccount(name, balance): a constructor that creates a new account with a name and starting balance. getBalance(): a function that returns the balance of a specific account. deposit(amount): abstract function to be implemented in both Checking and SavingAccount classes. withdraw(amount): abstract function to be implemented in both Checking and SavingAccount classes. messageTo Client (message): used to print...

  • 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....

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