Académique Documents
Professionnel Documents
Culture Documents
h>
#include<conio.h>
#include<stdio.h>
#include<math.h>
#include<iomanip.h>
#include<stdlib.h>
class account {
unsigned long int acno;
struct loan {
float pri, amt, rate, years;
};
loan x;
struct date {
int da_year;
int da_day;
int da_mon;
};
date dob;
int age;
char name[32];
char resi[65];
char mobile[15];
char aadhar_no[15};
char branch[18];
float balance;
public:
void getdata(char type);
void showdata();
void disptab()
{
cout<<setw(14)<<acno
<<setw(32)<<name
<<setw(15)<<balance
<<setw(17)<<branch
<<endl;
}
float retbal()
{
return(balance);
}
unsigned long int retacno()
{
return(acno);
}
};
void account::showdata()
{
cout<<�Account number: �<<acno<<endl;
cout<<�Name: �<<name<<endl;
cout<<�Age: �<<age<<endl;
cout<<�Date of Birth: �<<dob.da_day<<�/�
<<dob.da_mon<<�/�<<dob.da_year<<endl;
cout<<�Aadhar number: �<<aadhar_no<<endl;
cout<<�Mobile number: �<<mobile<<endl;
cout<<�Residential address: �<<resi<<endl;
cout<<�Balance: Rs�<<balance<<endl;
cout<<�Home Branch: �<<branch<<endl;
cout<<�Applied for loan: �;
if(x.amt)
{
cout<<�Yes�<<endl;
cout<<�Debt: Rs �<<x.amt<<endl;
}
else
cout<<�No�<<endl;
}
void saveaccount()
{
fstream save;
save.open(�bank.dat� , ios::app | ios::binary);
if(save)
{
char choice;
account a;
do
{
cout<<�File opened successfully ! \n�;
cout<<endl;
a.getdata(�a�);
save.write((char*)&a, sizeof(a));
cout<<�Would you like to register more �
<<�accounts? (Y/N): �;
cin>>choice;
}while( choice == �Y� || choice == �y� );
save.close();
}
else
cout<<�File not opened !! \n�;
}
Void searchacbyacno()
{
clrscr();
fstream file;
file.open(�bank.dat�, ios::in | ios::binary);
account a;
unsigned long int anum;
cout<<�Enter account number of required account: �;
cin>>anum;
cout<<endl;
int found=0;
while(found == 0 && file)
{
file.read((char*)&a, sizeof(a));
if(a.retacno() == anum)
found=1;
}
if(found == 1)
{
cout<<�Account found!�;
cout<<�The details are as given below: \n\n�;
a.showdata();
}
else
cout<<�Account not found !!�;
file.close();
}
void delac()
{
fstream file1,file2;
file1.open(�bank.dat�, ios::in | ios::binary);
file2.open(�temp.dat�, ioss::out | ios::binary);
long int gcode;
cout<<�Enter the account number: �;
cin>>gcode;
account a;
while(file1.read((char*)&a, sizeof(a)))
{
if(a.retacno() != gcode)
file2.write((char*)&a, sizeof(a));
}
cout<<�Account has been deleted successfully�;
file1.close();
file2.close();
remove(�bank.dat�);
rename(�temp.dat� , �bank.dat�);
}
void modac()
{
unsigned long int gcode;
cout<<�Enter account number: �;
cin>>gcode;
fstream file;
file.open(�bank.dat�, ios::in | ios::app | ios::binary);
account a;
int found=0;
while(file.read((char*)&a , sizeof(a)))
{
if(a.retacno() == gcode)
{
found = 1;
break;
}
}
if( found == 0 )
{
cout<<�Account does not exist�;
getch();
file.close(); return;
}
else if(found)
{
cout<<�Please enter account holder�s info�
<<� with changes: \n\n�;
a.getdata(�b�);
file.seekg(-sizeof(a),ios::cur);
file.write((char*)&a, sizeof(a));
}
file.close();
}
Void showac()
{
clrscr();
fstream file;
file.open(�bank.dat�, ios::in | ios::binary);
account a;
if(file)
{
cout<<�File opened successfully !! \n�;
if(file.read((char*)&a,sizeof(a)))
{
cout<<�All registered accounts are: \n\n�;
cout<<setw(14)<<�A/c No: �
<<setw(32)<<�Name of account holder: �
<<setw(15)<<�Balance: �
<<setw(17)<<�Branch: �<<endl;
file.seekg(0, ios::beg);
while(file.read((char*)&a, sizeof(a)))
a.disptab();
}
else
cout<<�No accounts have been created !!�;
}
else
cout<<�Fie not opened !!�;
}
Int isstaff()
{
char code[5] = { �Hello� };
int access = 1;
char input[5];
cout<<�Enter the access code: �;
for(int i=0; i<5; i++)
{
input[i] = getch();
cout<<�*�;
}
getch();
cout<<endl;
for(i=0; i<5; i++)
if( input[i] != code[i] )
{
access = 0;
break;
}
if( access == 1 )
return(1);
else
return(0);
}
void menustaff()
{
cout<<�\n\t\t\t STAFF USER INTERFACE \n\n\n�;
cout<<� Press 1: Register new account (s). �<<endl;
cout<<� Press 2: View accounts list. �<<endl;
cout<<� Press 3: View info of an account. �<<endl;
cout<<� Press 4: Modify an account�s info. �<<endl;
cout<<� Press 5: Delete an account. �<<endl;
cout<<� Press 6: Back to main menu. �<<endl;
cout<<� Enter your choice: �;
}
void menucustomer()
{
cout<<�\n\t\t\t ACCOUNT HOLDER USER INTERFACE\n�;
cout<<� Press 1: View account info. �<<endl;
cout<<� Press 2: Modify your account info. �<<endl;
cout<<� Press 3: Apply for a loan. �<<endl;
cout<<� Press 4: Back to the main menu �<<endl;
cout<<� Enter your choice: �;
}
void main()
{
clrscr();
account a;
int driver, opt;
do
{
clrscr();
driver = 0;
opt = 0;
cout<<�\n\t\t WELCOME TO JDT BANK !! \n �;
cout<<�\t\t\t MAIN MENU \n\n\n �;
cout<<� Press 1: For Account Holders�<<endl;
cout<<� Press 2: For Bank Staff�<<endl;
cout<<� Press 3: To Exit�<<endl;
cout<<�Enter your choice: �;
cin>>driver;
switch(driver)
{
case 1:
{
do
{
opt = 0;
clrscr();
menucustomer();
cin>>opt;
switch(opt)
{
case 1:
{
searchacbyacno();
getch();
break;
}
case 2:
case 3:
{
modac();
getch();
break;
}
case 4: break;
default:
{
cout<<�Invalid Input�;
getch();
}
}
)while(opt != 4);
break;
}
case 2:
{
clrscr();
if( isstaff() )
{
do
{
opt = 0;
clrscr();
menustaff();
cin>>opt;
switch(opt)
{
case 1:
{
saveaccount();
getch();
break;
}
case 2:
{
showac();
getch();
break;
}
case 3:
{
searchacbyacno();
getch();
}
case 4:
{
clrscr();
modac();
getch();
break;
}
case 5:
{
clrscr();
delac();
getch();
break;
}
case 6: break;
default:
{
cout<<�Invalid Input�;
getch();
}
}
}whle( opt != 6 );
}
else
{
cout<<�Invalid Input !!�;
getch();
}
break;
}
case 3:
{
cout<<�\n\n Thank you for using JDT �
<<�Bank UI !!�;
getch();
exit(0);
}
default:
{
cout<<�Invalid Input !!!�;
getch();
}
}
}while(driver != 3);
}