Sie sind auf Seite 1von 14

PROJECT

SUBMITTED TO:
Madam Asma Sajjad

Submitted by:
Rimsha Rizwan

Project.h*
#include<iostream>
#include<fstream>
#include<cctype>
#include<iomanip>
using namespace std;

class account
{
int ano;
char name[100];
int dep;
char type;
public:
void create_acc();
void show_acc();
void modify();
void adep(int);
void draw(int);
void report();
int retano();
int retbal();
char qtype();
};
void account::create_acc()
{

cout<<"\nEnter The Account Number :";


cin>>ano;
cout<<"\nEnter Name of The Account Holder : ";
cin.ignore();
fgets(name,100,stdin);
cout<<"\nEnter Type of Account (Current/Savings) : ";
cin>>type;
cout<<"\nEnter The Initial amount(>=500 for Saving and >=1000 for current ) :
";
cin>>dep;
cout<<"\n\n\nCongrats Account Has Been Created..";
}
void account::show_acc()
{
cout<<"\nAccount Number : "<<ano;
cout<<"\nAccount Holder Name : "<<name<<endl;
cout<<"\nType of Account : "<<type;
cout<<"\nBalance amount : "<<dep;
}
void account::modify()
{
cout<<"\nAccount Number : "<<ano;
cout<<"\nModify Account Holder Name : ";
cin.ignore();
fgets(name,100,stdin);
cout<<"\nModify Type of Account : ";
cin>>type;

cout<<"\nModify Balance amount : ";


cin>>dep;
}
void account::adep(int x) //adep means accept deposit
{
dep+=x;
}
void account::draw(int x) //subtract amount
{
dep-=x;
}
void account::report()
{
cout<<ano<<setw(10)<<" "<<name<<setw(10)<<"
"<<type<<setw(6)<<dep<<endl;
}
int account::retano() //return account number
{
return ano;
}
int account::retbal() //return balance
{
return dep;
}
char account::qtype()
{
return type;

//returning type of account

}
void write_acc();

//function to write record in binary file

void display(int);

//function to display account details given by user

void modify_acc(int);
void delete_acc(int);
void display_all();
void dep_withdraw(int, int); // function to desposit/withdraw amount for given
account
void intro();
void write_acc()
{
account ac;

//You can say it containership or has a relation...

ofstream x;
x.open("info.exe",ios::binary|ios::app);
ac.create_acc();
x.write(reinterpret_cast<char *> (&ac), sizeof(ac));
x.close();
}
void display(int n)
{
account ac;
bool flag=false;
ifstream x;
x.open("info.exe",ios::binary);
if(!x)
{
cout<<"File could not be opened!! Press any Key to exit...";

return;
}
cout<<"\nBALANCE DETAILS\n";
while(x.read(reinterpret_cast<char *> (&ac), sizeof(ac)))
{
if(ac.retano()==n)
{
ac.show_acc();
flag=true;
}
}
x.close();
if(flag==false)
cout<<"\n\nAccount number does not exist";
}
void modify_acc(int n)
{
bool found=false;
account ac;
fstream x;
x.open("info.exe",ios::binary|ios::in|ios::out);
if(!x)
{
cout<<"File could not be open !! Press any Key...";
return;
}

while(!x.eof() && found==false)


{
x.read(reinterpret_cast<char *> (&ac), sizeof(ac));
if(ac.retano()==n)
{
ac.show_acc();
cout<<"\n\nEnter The New Details of account"<<endl;
ac.modify();
int pos=(-1)*static_cast<int>(sizeof(account));
x.seekp(pos,ios::cur);
x.write(reinterpret_cast<char *> (&ac), sizeof(ac));
cout<<"\n\n\t Record Updated";
found=true;
}
}
x.close();
if(found==false)
cout<<"\n\n Record Not Found ";
}
void delete_acc(int n)
{
account ac;
ifstream x;
ofstream y;
x.open("info.exe",ios::binary);
if(!x)

{
cout<<"File could not be open !! Press any Key...";
return;
}
y.open("Temp.exe",ios::binary);
x.seekg(0,ios::beg);
while(x.read(reinterpret_cast<char *> (&ac), sizeof(ac)))
{
if(ac.retano()!=n)
{
y.write(reinterpret_cast<char *> (&ac), sizeof(ac));
}
}
x.close();
y.close();
remove("info.exe");
rename("Temp.exe","info.exe");
cout<<"\n\n\tRecord Deleted ..";
}
void display_all()
{
account ac;
ifstream x;
x.open("info.exe",ios::binary);
if(!x)
{

cout<<"File could not be open !! Press any Key...";


return;
}
cout<<"\n\n\t\tACCOUNT HOLDER LIST\n\n";
cout<<"=============================================
=======\n";
cout<<"A/c no.

NAME

Type Balance\n";

cout<<"=============================================
=======\n";
while(x.read(reinterpret_cast<char *> (&ac), sizeof(ac)))
{
ac.report();
}
x.close();
}
void dep_withdraw(int n, int option)
{
int amt;
bool found=false;
account ac;
fstream x;
x.open("info.exe", ios::binary|ios::in|ios::out);
if(!x)
{
cout<<"File could not be open !! Press any Key...";
return;

}
while(!x.eof() && found==false)
{
x.read(reinterpret_cast<char *> (&ac), sizeof(ac));
if(ac.retano()==n)
{
ac.show_acc();
if(option==1)
{
cout<<"\n\n\tTO DEPOSITE AMOUNT ";
cout<<"\n\nEnter The amount to be deposited";
cin>>amt;
ac.adep(amt);
}
if(option==2)
{
cout<<"\n\n\tTO WITHDRAW AMOUNT ";
cout<<"\n\nEnter The amount to be withdraw";
cin>>amt;
int bal=ac.retbal()-amt;
if((bal<500 && ac.qtype()=='S') || (bal<1000 && ac.qtype()=='C'))
cout<<"Insufficience balance";
else
ac.draw(amt);
}
int pos=(-1)*static_cast<int>(sizeof(ac));

x.seekp(pos,ios::cur);
x.write(reinterpret_cast<char *> (&ac), sizeof(ac));
cout<<"\n\n\t Record Updated";
found=true;
}
}
x.close();
if(found==false)
cout<<"\n\n Record Not Found ";
}
void intro()
{
cout<<"***********************************"<<endl;
cout<<"\nWELCOME TO RIMSHA BANK MANAGEMENT SYSTEM";
cout<<"\nPress Enter To Continue........";
cin.get();
}
Project.cpp
#include<iostream>
#include<stdlib.h>
#include"project.h"
using namespace std;
int main()
{
char ch;
int num;

intro();
do
{
system("cls");
cout<<"\n\n\n\tACTION MENU";
cout<<"\n\n\t01. NEW ACCOUNT";
cout<<"\n\n\t02. DEPOSIT";
cout<<"\n\n\t03. WITHDRAW";
cout<<"\n\n\t04. BALANCE ENQUIRY";
cout<<"\n\n\t05. COMPLETE ACCOUNT HOLDERS LIST";
cout<<"\n\n\t06. CLOSE AN ACCOUNT";
cout<<"\n\n\t07. MODIFY AN ACCOUNT";
cout<<"\n\n\t08. EXIT";
cout<<"\n\n\tSelect Your Option (1-8) ";
cin>>ch;
system("cls");
switch(ch)
{
case '1':
write_acc();
break;
case '2':
cout<<"\n\n\tEnter The Account Number : "; cin>>num;
dep_withdraw(num, 1);
break;
case '3':

cout<<"\n\n\tEnter The Account Number : "; cin>>num;


dep_withdraw(num, 2);
break;
case '4':
cout<<"\n\n\tEnter The Account Number : "; cin>>num;
display(num);
break;
case '5':
display_all();
break;
case '6':
cout<<"\n\n\tEnter The Account Number : "; cin>>num;
delete_acc(num);
break;
case '7':
cout<<"\n\n\tEnter The Account Number : "; cin>>num;
modify_acc(num);
break;
case '8':
cout<<"\nThanks For Visiting Our Bank!";
break;
default :cout<<"\a Please choose a valid option between 1-8... Enter to
Continue.";
}
cin.ignore();
cin.get();
}while(ch!='8');

return 0;
system("pause");
}

Das könnte Ihnen auch gefallen