Professional Documents
Culture Documents
#include<fstream>
#include<string>
#include<iomanip>
#include<stdlib.h>
#include<stdio.h>
#include<windows.h>
#include<process.h>
#include<conio.h>
const int size=50;
using namespace std;
class NewAccount
{
int account_id,pass,age; float balance; char name[size],address[size];
void storeInfo();
void depositFunds();
void withdrawFunds();
void updateAccount();
void deleteAccount();
void showInfo();
public:
NewAccount() : account_id(),pass(),balance(),age()
{
strcpy(name,"");
strcpy(address,"");
}
class AError{};
class BError{};
void signupAccount();
void signinAccount();
void viewAllInfo();
};
system("pause");
system("CLS");
cout << "\n Welcome " << name << "!" << endl;
cout << "Please Follow the Instruction Given
Below"<<endl;
cout << "\n* Press 1) to Deposit Funds"<<endl;
cout << "* Press 2) to Withdraw Funds"<<endl;
cout << "* Press 3) to View Account Details"<<endl;
cout << "* Press 4) to Update Account Details"<<endl;
cout << "* Press 5) to Delete Your Account"<<endl;
cout << "* Press 6) to Exit Your Account"<<endl;
cout << "\nEnter Your Choice: "; cin>> choice;
while(1)
{
switch(choice)
{
case 1:
system("CLS");
depositFunds();
c1 = file.tellg();
c2 = sizeof*this;
file.seekg(c1-c2);
file.write(reinterpret_cast<char*>(this) , sizeof(*this) );
break;
case 2:
system("CLS");
withdrawFunds();
c1 = file.tellg();
c2 = sizeof*this;
file.seekg(c1-c2);
file.write(reinterpret_cast<char*>(this) , sizeof(*this) );
system("pause");
break;
case 3:
system("CLS");
showInfo();
system("pause");
break;
case 4:
system("CLS");
temp = *this;
temp.updateAccount();
cout << "\n\t\t* Enter 'Y' to save these
Changes" << endl;
cout << "\n\t\t* Enter any key to Discard
these Changes" << endl;
cout << "Enter Your Choice: "; cin >>
ch;
if(ch=="Y" || ch == "y")
{
*this = temp;
c1 = file.tellg();
c2 = sizeof*this;
file.seekg(c1-c2);
file.write(reinterpret_cast<char*>(this) , sizeof(*this) );
cout << "\n\t* Changes are
Sucessfully Saved!!" << endl;
system("pause");
break;
}
else
{
break;
}
case 5:
file.close();
system("CLS");
cout << "\n\n\t\t* Enter 'Y' to Delete
Your Account" << endl;
cout << "\n\t\t* Enter any key to Discard
Deletion" << endl;
cout << "Enter Your Choice: "; cin >>
ch;
if(ch=="Y" || ch == "y")
{
deleteAccount();
system("pause");
}
break;
case 6:
file.close();
system("CLS");
cout << "\n\t\t** You Account is Sign out
**"<< endl;
cout << "\n\tThanks For Using Our Bank
Service!\n"<<endl;
system("pause");
break;
default:
cout << "Error! Your Entry is Invalid"
<<endl;
system("pause");
break;
}
system("CLS");
if(choice!=6 && choice !=5)
{
cout << "\t\t\t***** Welcome " << name << "
****" << endl;
cout << "Please Follow the Instruction Given
Below"<<endl;
cout << "\n* Press 1) to Deposit Funds"<<endl;
cout << "* Press 2) to Withdraw Funds"<<endl;
cout << "* Press 3) to View Account
Details"<<endl;
cout << "* Press 4) to Update Account
Details"<<endl;
cout << "* Press 5) to Delete Your
Account"<<endl;
cout << "* Press 6) to Exit Your
Account"<<endl;
cout << "\nEnter Your Choice: "; cin>> choice;
system("CLS");
}
else
{
break;
}
}
}
file.read(reinterpret_cast<char*>(this) ,
sizeof(*this) );
}
if(log==false)
{
cout << "\tLogin Failed!" << endl;
system("pause");
}
file.close();
}
}
while(!fin.eof())
{
showInfo();
fin.read(reinterpret_cast<char*>(this) , sizeof(*this) );
}
fin.close();
}
}
void NewAccount::depositFunds()
{
float b;
cout << "Enter the Deposit Balance: "; cin>>b;
balance += b;
}
break;
}
else
{
cout << "Error! your Age is Less than 18" <<endl;
break;
}
case 6:
break;
default:
cout << "Error! Your Entry is Invalid" << endl;
break;
}
if(choice<1 || choice>6 )
{
system("CLS");
cout << "\n\t\t\t**** Update Your Profile ****" << endl;
cout << "\n\t\t* Press 1) to Update Your Name"<<endl;
cout << "\t* Press 2) to Update Your Password"<<endl;
cout << "\t* Press 3) to Update Your Age"<<endl;
cout << "\t* Press 4) to Update Your Address"<<endl;
cout << "\t* Press 5) to Update Your Whole Profile"<<endl;
cout << "\t* Press 6) to Discard Any Update"<<endl;
cout << "\nEnter Your Choice: ";
cin>> choice;
}
else
break;
}
}
void NewAccount :: deleteAccount()
{
NewAccount temp; bool y=false;
ifstream fin; ofstream fout;
fin.open("Bank.txt",ios::binary);
if(!fin)
{
cout << "\nError! Data file not found" << endl;
}
else
{
fin.read(reinterpret_cast<char*>(&temp),sizeof(temp));
fout.open("Temp.txt",ios::binary);
while(!fin.eof())
{
if( strcmp(name , temp.name) && !(pass == temp.pass) )
{
fout.write(reinterpret_cast<char*>(&temp),sizeof(temp));
y = true;
}
fin.read(reinterpret_cast<char*>(&temp),sizeof(temp));
}
if(y == false)
{
cout << "\n\n\t\t*** Deletion Unsucessful ***" << endl;
}
else
{
cout << "\n\n\t\t *** Your Account is Sucessfully Deleted ***" <<
endl;
}
fin.close(); fout.close();
remove("Bank.txt");
rename("Temp.txt","Bank.txt");
}
}
int main()
{
try
{
NewAccount obj; int choice;
//obj.viewAllInfo();
system("color 1B");
Sleep(1000);
cout<<"\n\t\t****Project Title: Bank Account System****\n\n";
Sleep(1000);
cout<<"Group Members: "<<endl<<endl;
Sleep(1000);
cout<<"(1). Rana Muhmmad Usman Shahid "<<endl;
Sleep(1000);
cout<<"\n(2). Hafiz Muhammad Awais Bajwa "<<endl;
Sleep(1000);
cout<<"\n(3). Junaid Ahmad Shahid "<<endl;
Sleep(2000);
system("CLS");