By not changing anything in the program. You have been developing a BankAccount
ID: 3544563 • Letter: B
Question
By not changing anything in the program.
You have been developing a BankAccount class for parkville Bank that contains several fields and functions.
a) Add Arithmetic operators that operate as follows:
b. Include < and > operators that determine whether one account is less than or greater than another. These comparisons are based on balances. Include an == operator that makes a comparison based on account number.
c.Include extraction and insertion operators for the class.
d. If you do not already have one, creat a default constructor that assigns 0 to all the class fields.
e. Write an main() function that declares an array of five BankAccount objects. (use the default construtor, so all the data fields will be initialized to 0s) For each account, prompt the user for a series of transations. The user enters a positive number for each deposit, a negative number for each withdrawal, and a 0 to quit entering transactions for an account. After the user has entered transactions for all five accounts, display the resulting details for each BankAccount.
f. After the main() function so that the user is prompted for starting account data instead of accepting the default 0 values.
g. Modify the main() function so that no two accounts are allowed with the same account number. Reprompt the user for a new account number when a duplicate occurs.
h. Modify the main() function to display the data for the accounts with the highest and lowest balances after all the data has been entered.
#include<iostream>
using namespace std;
#include <stdlib.h>
class BankAccount
{
friend ostream& operator<<(ostream&, BankAccount);
friend istream& operator>>(istream&, BankAccount&);
private:
int acctNum;
double balance;
double annualRate;
public:
BankAccount(int, double = 0.0, double = 0.0);
BankAccount();
void enterAccountData();
void computeInterest(int);
void displayAccount();
BankAccount operator+=(double);
BankAccount operator-=(double);
BankAccount operator+(const BankAccount&);
bool operator<(BankAccount);
bool operator>(BankAccount);
bool operator==(BankAccount);
};
BankAccount::BankAccount(int acct, double bal, double rate)
{
}
BankAccount::BankAccount()
{
}
void BankAccount::enterAccountData()
{
}
void BankAccount::computeInterest(int years)
{
}
void BankAccount::displayAccount()
{
}
BankAccount BankAccount::operator+=(double deposit)
{
}
BankAccount BankAccount::operator-=(double withdrawal)
{
}
BankAccount BankAccount::operator+(const BanAccount &acct)
{
BanAccount sum(9999, 0);
sum.balance = BankAccount::balance + acct.balance;
return sum;
}
bool BankAccount::operator>(BankAccount account)
{
}
bool BankAccount::operator<(BankAccount account)
{
}
bool BankAccount::operator==(BankAccount account)
{
}
ostream& operator<<(ostream& out, BankAccount account)
{
}
istream& operator>>(istream& in, BankAccount& account)
{
}
int main()
{
BankAccount myAccount, yourAccount (1111, 100, 0.12);
double increment = 4.50; int val = 2;
//the following statment demonstrate that your overloaded insertion operators works
cout << myAccount <<endl;
cout <<yourAccount<<endl;
//the following statement demonstrate that your extraction operator works
cin >> myAccount;
//The following statement dipalys that += ans -= work
myAccount += increment;
cout <<myAccount;
myAccount -= increment;
cout <<myAccount;
//The following statements demonstrate that the + operaotr works
BankAccount temp;
temp = myAccount + yourAccount;
cout <<temp;
//The following statements demonstrate that the < operaotr works
cout <<(myAccount<yourAccount);
//The following statements demonstrate that the > operaotr works
cout <<(myAccount>yourAccount);
//The following statements demonstrate that the == operaotr works
cout <<(myAccount==yourAccount);
system ("PAUSE");
return 0;
}
Explanation / Answer
please see here
pastebin.com/4R6x13hb
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.