Question: #include #include #include #include #include using namespace std; / / account skeleton class BankAccount { public: int accNumber; / / acoount number char fName; /

#include
#include
#include
#include
#include
using namespace std;
// account skeleton
class BankAccount
{
public:
int accNumber; //acoount number
char fName; // first name
char lname;// last name
char phoneNum ; //phone number
char street ;
char City ;
char postcode;
double balance;
BankAccount( int accNumber, char fName, char lname, char phoneNum, char street, char City, char postcode, double balance )
{
this -> accNumber = accNumber;
this -> fName= fName;
this -> lname= lname;
this -> phoneNum= phoneNum;
this -> street= street;
this -> City = City;
this -> postcode = postcode;
this ->balance= balance;
}
bool operator ==(const BankAccount& a)const
{
return a.accNumber==accNumber;
}
};
void readAcc( const char& filename, vector Account)//reading accounts
{
ifstream file(filename);
if (file.is_open())
{
int accNumber;
char fName, lname,phoneNum,street,City,postcode;
double balance;
while(file>>accNumber>>fName>>lname>>phoneNum>>street>>City>>postcode>>balance)
{
Account.push_back(BankAccount(accNumber, fName, lname,phoneNum,street,City,postcode,balance));
}
file.close();
}
else
{
cout<<"File cannot be read!"< Account)
{
ofstream file(filename);
if (file.is_open())
{
for(const auto& account : Account )
{
file<Account;
cout<<"o: Open Account: "<>accNumber;
for (auto& account : Account){
if (account.accNumber == accNumber){
account.balance += amount;
cout << amount <<" deposited to account "<< accNumber << endl;
break;
}
}
break;
case 'w':
cout << "Enter withdrawal amount: ";
cin >> amount;
for (auto& account : Account){
if (account.accNumber == accNumber){
if (account.balance >= amount){
account.balance -= amount;
cout << amount <<" withdrawn from account "<< accNumber << endl;
} else {
cout << "Insufficient funds in account "<< accNumber << endl;
}
break;
}
}
break;
case 'a':
case 's':
cout<<"Account Number: ";
cin>>accNumber;
break;
case 'p':
break;
default:
continue;
}
}
}
return 0;
}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!