Oct 7, 2018 at 11:07pm UTC
Hello everyone. I'm confused on how to create an interest rate and a saving/checking account into the code. Help will be greatly appreciated!
#include <iostream>
#include <string>
using namespace std;
class BankAccount
{
private:
int accountnumber;
string name;
double balance;
string checkingaccount;
string savingaccount;
static int totalaccounts;
static double bankbalance;
public:
BankAccount();
BankAccount(string, int, double);
~BankAccount();
string getname() const;
double getBalance() const;
int getaccountnumber() const;
double getinterestrate() const;
void setinterestrate(double rate);
void setname(string);
void setaccountnumber(int);
void setBalance(double);
void withdraw(double);
void deposit(double);
void rate(double);
static void printBankAccountinfo();
};
string BankAccount::getinterestrate() const
{
return rate;
}
string BankAccount::getname() const
{
return name;
}
double BankAccount::getBalance() const
{
return balance;
}
int BankAccount::getaccountnumber() const
{
return accountnumber;
}
BankAccount::BankAccount()
{
accountnumber = 0;
balance = 0.0;
totalaccounts++;
}
BankAccount::BankAccount(string newName, int newAccountNumber, double newBalance)
{
name = newName;
accountnumber = newAccountNumber;
totalaccounts++;
balance = newBalance;
bankbalance += newBalance;
}
int BankAccount::totalaccounts = 0;
double BankAccount::bankbalance = 10000;
BankAccount::~BankAccount()
{
totalaccounts--;
bankbalance -= balance;
}
void BankAccount::setname(string newName)
{
name = newName;
}
void BankAccount::setaccountnumber(int newAccountNumber)
{
accountnumber = newAccountNumber;
}
void BankAccount::setBalance(double newBalance)
{
bankbalance -= balance;
balance = newBalance;
bankbalance += balance;
}
void BankAccount::withdraw(double withdraw)
{
balance -= withdraw;
bankbalance -= withdraw;
}
void BankAccount::deposit(double deposit)
{
balance += deposit;
bankbalance += deposit;
}
void BankAccount::printBankAccountinfo()
{
cout << "Number of Accounts: " << totalaccounts << endl;
cout << "Total Balance: " << bankbalance << endl;
}
int main ()
{
BankAccount::printBankAccountinfo();
system("pause");
}
Last edited on Oct 7, 2018 at 11:07pm UTC