1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85
|
string name,account_no,account_no_check,ballance;
cout<<"\tCreate Account\n\n\t";
cout<<"\tEnter Customer Account Number: ";
cin>>account_no_check;
fstream create("Accounts.txt",ios::app|ios::in|ios::out);
while(std::getline(create,name)&&std::getline(create,account_no)&&std::getline(create,ballance))
{
if(account_no_check==account_no)
{
system("cls");
cout<<account_no;
cout<<name;
cout<<ballance;
string choose;
create.close();
cout<<"\n\n\n\tEnter 1 For Deposite Money\n\tEnter 2 For Withdraw Money";
cin>>choose;
if(choose=="1")
{
float withdraw,Money;
cout<<"Amount to withdraw: ";
cin>>withdraw;
Money=std::stof(ballance);
Money=withdraw+Money;
fstream temp("temp.txt",ios::binary|ios::in|ios::out);
temp<<account_no<<'\n';
temp<<name<<'\n';
temp<<Money<<'\n';
temp<<'\n';
temp.close();
create.open("Accounts.txt",ios::binary|ios::in|ios::out);
while(std::getline(create,name)&&std::getline(create,account_no)&&std::getline(create,ballance))
{
temp<<account_no<<'\n';
temp<<name<<'\n';
temp<<ballance<<'\n';
temp<<'\n';
}
remove("Accounts.txt");
rename("temp.txt","Account.txt");
return 0;
}
else
{
if(choose=="2")
{
float deposite,Money;
cout<<"amount: ";
cin>>deposite;
Money=std::stof(ballance);
Money=Money-deposite;
fstream temp("temp.txt",ios::binary|ios::in|ios::out);
temp<<account_no<<'\n';
temp<<name<<'\n';
temp<<Money<<'\n';
temp<<'\n';
temp.close();
create.open("Accounts.txt",ios::binary|ios::in|ios::out);
while(std::getline(create,name)&&std::getline(create,account_no)&&std::getline(create,ballance))
{
temp<<account_no<<'\n';
temp<<name<<'\n';
temp<<ballance<<'\n';
temp<<'\n';
}
remove("Accounts.txt");
rename("temp.txt","Account.txt");
return 0;
}
else
{
if(choose=="3")
{
cout<<"Delete Account";
}
}
else
{
cout<<"incorrect name or password";
return 0;
}
}
|