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<

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
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
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education