can you please remove error from deposit and withdraw section. #include #include #include using namespace std; string user; string pass; void Register(); int LoginCheck (string user, string pass); class Bank { protected: int accountNumber; string fname; string lname; string CNIC; long balance; public: void openAccount(int accountNumber, string fname,string lname,string CNIC,long balance); void checkBalance(int find); void depositeAmount(int f); void withdrawAmount(int f); void removeAccount(int find); virtual void stdisplayall() = 0; }; class data{ public: int accountNumber; string fname; string lname; string CNIC; long balance; }; class Account: public Bank { data obj[10]; public: void openAccount(int accountNumber, string fname,string lname,string CNIC,long balance) { fstream myFile; myFile.open("temp.txt",ios::app); if (!myFile.is_open()) { cout << "file not found" << endl; } else { this->accountNumber = accountNumber; this->fname = fname; this->lname = lname; this->CNIC = CNIC; this->balance = balance; myFile<>obj[i].accountNumber; myfile>>obj[i].balance; myfile>>obj[i].fname; myfile>>obj[i].lname; myfile>>obj[i].CNIC; } string name; int updateamount; cout<<"Enter account holder name to update baalnce"<>name; for(int i=0;i<10;i++) { if(name==obj[i].fname) { cout<<"ENter amount you want to update"<>updateamount; obj[i].balance = obj[i].balance + updateamount; setdata<>accountNumber; if(accountNumber==f) { notFound = 1; cout<<"Account Number is : "<>balance; cout<<"Total Available balance : "<>obj[i].accountNumber; myfile>>obj[i].balance; myfile>>obj[i].fname; myfile>>obj[i].lname; myfile>>obj[i].CNIC; } string name; int updateamount; cout<<"Enter account holder's First Name to withdraw baalnce :"; cin>>name; cout<>updateamount; cout<=updateamount) { obj[i].balance = obj[i].balance - updateamount; setdata<

C++ for Engineers and Scientists
4th Edition
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Bronson, Gary J.
Chapter12: Adding Functionality To Your Classes
Section: Chapter Questions
Problem 1PP
icon
Related questions
Question

can you please remove error from deposit and withdraw section.

#include<iostream>
#include<fstream>
#include<string>
using namespace std;

string user;
string pass;

void Register();
int LoginCheck (string user, string pass);

class Bank
{
protected:
int accountNumber;
string fname;
string lname;
string CNIC;
long balance;
public:

void openAccount(int accountNumber, string fname,string lname,string CNIC,long balance);
void checkBalance(int find);
void depositeAmount(int f);
void withdrawAmount(int f);
void removeAccount(int find);
virtual void stdisplayall() = 0;
};
class data{
public:
int accountNumber;
string fname;
string lname;
string CNIC;
long balance;
};
class Account: public Bank
{ data obj[10];
public:
void openAccount(int accountNumber, string fname,string lname,string CNIC,long balance)
{
fstream myFile;
myFile.open("temp.txt",ios::app);

if (!myFile.is_open())
{
cout << "file not found" << endl;
}
else
{
this->accountNumber = accountNumber;
this->fname = fname;
this->lname = lname;
this->CNIC = CNIC;
this->balance = balance;

myFile<<accountNumber<<endl;
myFile<<balance<<endl;
myFile<<fname<<endl;
myFile<<lname<<endl;
myFile<<CNIC<<endl;

}
}
void depositeAmount(int find)
{

ifstream myfile;
myfile.open("temp.txt");
ofstream setdata;
setdata.open("usernew.txt",ios::app);

int notFound = 0;
for (int i=0;i<1;i++)
{
myfile>>obj[i].accountNumber;
myfile>>obj[i].balance;
myfile>>obj[i].fname;
myfile>>obj[i].lname;
myfile>>obj[i].CNIC;
}
string name;
int updateamount;
cout<<"Enter account holder name to update baalnce"<<endl;
cin>>name;
for(int i=0;i<10;i++)
{
if(name==obj[i].fname)
{
cout<<"ENter amount you want to update"<<endl;
cin>>updateamount;
obj[i].balance = obj[i].balance + updateamount;
setdata<<obj[i].accountNumber<<endl;
setdata<<obj[i].balance<<endl;
setdata<<obj[i].fname<<endl;
setdata<<obj[i].lname<<endl;
setdata<<obj[i].CNIC<<endl;
}
}

setdata.close();
myfile.close();
remove("temp.txt");
rename("usernew.txt","temp.txt");
exit(1);


if(notFound == 0)
{
cout<<"No Record Found"<<endl;
}

}
void checkBalance(int f)
{
fstream myfile;
myfile.open("temp.txt");
int notFound = 0;
while( !myfile.eof())
{
myfile>>accountNumber;

if(accountNumber==f)
{
notFound = 1;

cout<<"Account Number is : "<<accountNumber<<endl;
myfile>>balance;
cout<<"Total Available balance : "<<balance<<endl;
if(balance<500)
{
cout<<"\n Your balance is very low.\n";
}
}
}

if(notFound == 0)
{
cout<<"No Record Found"<<endl;
}
myfile.close();
}

void withdrawAmount(int find)
{

ifstream myfile;
myfile.open("temp.txt");
ofstream setdata;
setdata.open("usernew.txt",ios::app);

int notFound = 0;
for (int i=0;i<10;i++)
{
myfile>>obj[i].accountNumber;
myfile>>obj[i].balance;
myfile>>obj[i].fname;
myfile>>obj[i].lname;
myfile>>obj[i].CNIC;
}

string name;
int updateamount;
cout<<"Enter account holder's First Name to withdraw baalnce :";
cin>>name;
cout<<endl;
for(int i=0;i<10;i++)
{
if(name==obj[i].fname)
{
cout<<"ENter amount you want to withdraw :";
cin>>updateamount;
cout<<endl;
int m = balance - 500;
if(m>=updateamount)
{
obj[i].balance = obj[i].balance - updateamount;
setdata<<obj[i].accountNumber<<endl;
setdata<<obj[i].balance<<endl;
setdata<<obj[i].fname<<endl;
setdata<<obj[i].lname<<endl;
setdata<<obj[i].CNIC<<endl;
system("cls");
cout<<"\nAmount withdraw Successfully\n";
cout<<"Your remaing balance is :"<<obj[i].balance;
}
else
{
cout<<"\nYou have insufficient balance\n";
}

}
}

setdata.close();
myfile.close();
remove("temp.txt");
rename("usernew.txt","temp.txt");
exit(1);


if(notFound == 0)
{
cout<<"No Record Found"<<endl;
}

}

 

Expert Solution
steps

Step by step

Solved in 2 steps with 2 images

Blurred answer
Knowledge Booster
ADT and Class
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ for Engineers and Scientists
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning