Beruflich Dokumente
Kultur Dokumente
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()
{
}
void write_acc();
void display(int);
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;
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;
}
{
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)
{
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':
return 0;
system("pause");
}