#include<iostream.h>
#include<fstream.h>
#include<process.h>
#include<string.h>
#include<stdlib.h>
#include<stdio.h>
#include<ctype.h>
#include<conio.h>
#include<dos.h>
#include<iomanip.h>
class Menus
{
public :
void showmenu(void) ;
private :
void closemenu(void) ;
};
class disRecords
{
public :
void addDeatails(int,char name[50],char address[100],float);
void displaycustomers(void);
void deleteAccount(int);
void updateBalance(int,float);
void updateCustomer(void);
int lastAccount(void);
int accountExists(int);
char *getName(int);
char *getAddress(int);
float getBalance(int);
int getRecord(int);
void display(int);
void displaylist(int);
int Accountnumber;
char name[50], address[50];
float intBalance;
};
class accountTransactions
{
public :
void new_account(void);
void closeAccount(void);
void display_account(void);
void transaction(void);
void addDetails(int,int,int,int,char,char typeTransaction[15],float,float,float);
void deleteAccount(int);
int dateDiffer(int,int,int,int,int,int);
float getInterest(int, float);
void display(int);
void showAccount(int);
int AccountNumber;
char trantype[10];
int dday,mmont,yyear;
char transactions;
float intInterest, intamount, intBalance;
static float calcInterest;
void showInterest(void);
};
void Menus :: showmenu(void)
{
char choice;
while(1)
{
clrscr();
cout<<" \n ------- Welcome to Banking System Application ------- \n";
cout<<"********************************************** \n \n";
cout<<" Choose form the Option \n";
cout<<" ___________________________________ \n";
cout<<" 1:Open an New Account \n";
cout<<" 2:View an Account \n";
cout<<" 3:Show all Accounts \n";
cout<<" 4:Make a Transaction \n";
cout<<" 5:Calculate Intreset \n";
cout<<" 6:Close an Account \n";
cout<<" 7:Exit \n \n";
cout<<" Pleas Select A choice : \n";
choice = getche();
if (choice == '1')
{
accountTransactions objAT;
objAT.new_account();
}
else
if (choice == '2')
{
accountTransactions objAT;
objAT.display_account();
}
else
if (choice == '3')
{
dispRecords newRec;
newRec.displayCustomers();
}
else
if (choice == '4')
{
accountTransactions objAT;
objAT.transaction();
}
else
if (choice == '5')
{
accountTransactions objAT;
objAT.showInterest();
}
else
if (choice == '6') {
closemenu();
}
else
if (choice == '7')
{
cout<<" \n Thanks for using this application . Please press any key to exit. \n ";
getch();
break;
}
}
}
void Menus :: closemenu(void)
{
char choice;
while (1)
{
clrscr();
cout<<" ---Close Menu--- \n";
cout<<" ****************************** \n";
cout<<" 1: Close/Delete an Account \n";
cout<<" 0: Exit from this menu. \n\n";
cout<<" Select a Choice : ";
choice = getche();
if (choice == '1')
{
accountTransactions at ;
at.closeAccount();
break;
}
else
if (choice == '0')
{
cout<<" \n You have Entered 0 to go back to the previeous Menu. \n";
getch();
break;
}
}
}
int dispRecords :: lastAccount(void)
{
fstream filename ;
filename.open("newrecords.dat", ios::in) ;
filename.seekg(0, ios::beg) ;
int count=0 ;
while (filename.read((char *) this, sizeof(dispRecords))) count = AccountNumber ;
filename.close();
return count;
}
int dispRecords :: getRecords(int retrieve_AccNo)
{
fstream filename;
filename.open("newrecords.dat", ios::in);
filename.seekg(0, ios::beg);
int count = 0;
while (filename.read((char*) this, sizeof(dispRecords)))
{
count++;
if (retriev_AccNo == AccoutnNumber)
break;
}
filename.close();
return count;
}
void dispRecords :: display(int retrieve_AccNo)
{
int record ;
record = getRecord(retrieve_AccNo) ;
fstream filename ;
filename.open("newrecords.dat",ios::in);
file.seekg(0,ios::end);
int location;
location = (record) = sizeof(dispRecords);
filename.seekp(loaction);
while (filename.read((char*) this, sizeof(dispRecords))
{
if (retrieve_AccNo == AccountNumber)
{
cout<<"\n ACCOUNT NO. :"<<Accountnumber;
cout<<"\n Name :"<<name;
cout<<"\n Address :"<<address;
cout<<"\n Balance :"<<intBalance;
break;
}
}
filename.close();
}
char *dispRecords :: getName(int retrieve_AccNo)
{
fstream filename;
filename.open("newrecords.dat", ios::int);
filename.seekg(0,ios::beg);
char retrieve_CustName[50];
while (filename.read((char*) this, sizeof(dispRecords)))
{
if (AccountNumber == retrieve_Accno)
{
strcpy(retrieve_CustName,name);
}
}
filename.close()l
return retrieve_CustName;
}
char*dispRecords :: getAddress (intRetrieve_AccNo)
{
fstream filename;
filename.open("newrecords.dat", ios::in);
filename.seekg(0,ios::beg);
char retrieve_Address[100];
while (filename.read((char*)this, sizeof(dispRecords)))
{
id (AccountNumer == retrieve_Accno)
{
strcpy(retrieve_Address,address);
}
}
filename.close();
return retrieve_Address;
}
float dispRecords :: getBalance(int retrieve_AccNo)
{
fstream filename;
filename.open("newrecords.dat",ios::in);
filename.seekg(0,ios::beg);
float iBalance;
while (filename.read((char*) this, sizeof(dispRecords)))
{
if (AccountNumber == retrieve_AccNo)
{
iBalance = intBalance;
}
}
filename.close();
return ibalance ;
}
int dispReecords :: accountExists(int, Retrieve_AccNo)
{
stream filename;
filename.open("newrecords.dat", ios::in);
filename.seekg(0;ios::beg);
int count=0;
while(filename.read((char*) this, sizeof(dispRecords)))
{
if (AccountNumber == retrieve_AccNo)
{
count = 1;
break;
}
}
filename.close();
return count;
}
void dispRecords :: displayList()
{
cout<<" \n " ;
int day1,mont1,year1 ;
struct date dateval ;
getdate(&dateval) ;
day1 = dateval.da_day ;
month1 = dateval.da_mon ;
year1 = dateval.da_year ;
cout<<" \n Date : " <<day1 <<"/" <<month1 <<"/" <<year1<<"\n";
cout<<setw(80)<<"__________________________________________\n";
cout<<setw(23)<<" ACCOUNT NO. ";
cout<<setw(23)<<"NAME OF PERSON";
count<<setw(23)<<"BALANCE \n";
cout<<setw(23)<<"_______________________________________\n";
}
void dispRecords :: displaycustomers (void)
{
clrscr()
int lenl;
int row=8, check;
fstream filename;
FILE = pFile;
pFile = fopen("newrecords.dat","r");
if (pFile == NULL)
{
cout<<"\n No Account Exists. Please go back to the previous menu. \n";
getch();
return;
//fclose (pFile);
}
else
{
displayList():
filename.open("newrecords.dat",ios::in);
filename.seekg(0,ios::beg);
while(filename.read((char*) this, sizeof(dispRecords)))
{
check = 0 ;
cout.fill (' ');
cout <<setw(20);
cout.setf(ios::right, ios::adjustfield);
cout<<AccountNumber;
cout.fill (' ');
cout <<setw(25);
cout.self(ios::internal, ios::adjustfield);
cout<<name;
cout<<setw(23);
cout.setf(ios::right,ios::adjustfield);
cout<<intBalance<<"\n";
row++;
if (row == 23)
{
check =1 ;
row = 8 ;
cout<<" \n\n Continue the Application ....... \n";
getch();
clrscr();
dispList();
}
}
}
filename.close();
if (!check)
{
cout<<"\n\n Continue the Application....... \n";
getch();
}
}
void dispRecords :: addDetails (int retrieve_AccNo, char retrieve_CustNmae[30],char retrieve_Address[60], float iBalance)
{
AccountNumber = retrieve_AccNo;
strcpy(nsme,retrieve_CustName);
strcpy(address,retrieve_Address);
intBalance = iBalance;
fstream filename;
filename.open("newrecords.dat", ios::out | ios::app);
filename.write((char*) this, sizeof(dispRecords));
filename.close();
}
void dispRecords :: deleteAccount(int retrieve_AccNo)
{
fstream.open("newrecords.dat", ios::in);
fstream temp;
temp.open("calculation.txt", ios::out);
filename.seekg(0,ios::beg);
while (filename.eof())
{
filename.read((char*) this, sizeof(disprecords));
if (filename.eof())
break;
if (AccountNumber !=retrieve_AccNo)
temp.write((char*) this, size(dispRecords));
}
filename.close();
temp.close();
filename.open("newrecords.dat", ios::out);
temp.open("calculations.txt", ios::in);
temp.seekg(0,ios::beg);
while ( !temp.eof())
{
temp.read((char*) this, sizeof(dispRecords));
if (temp.eof())
break;
filename.write((char*) this, sizeof(dispRecords));
}
filename.close();
temp.close();
}
void dispRecords :: updateBalance(int retrieve_AccNo, float iBalance)
{
int record ;
record = getRecord(retrieve_AccNo);
fstream filename;
filename.open("newrecords.dat", ios::out| ios::ate);
intBalance = iBalance;
int location;
location = (record-1)* sizeof(dispRecords);
filename.seekg(loaction);
filename.write((char*) this, sizeof(dispRecords));
filename.close();
}
void accountTransactions :: addDetails(int retrieve_AccNo, int dey1, int month1, iht year1, char t_tran, char typeTransaction[10], float interest_accrued, float t_amount, float iBalance)
{
fstream filename;
filename.open("transactions.dat", ios::app) ;
AccountNumber = retrieve_AccNo;
dday = day1;
mmonth1 = month1;
yyear1 = year1;
transaction = t_tran;
strcpy(trantype,typeTransaction);
intInterest = interest_accrued;
intAmount = t_amount;
intBalance = iBalance;
filename.write((char*) this, sizeof(accountTransactions));
filename.close();
}
void accountTrancastions :: deleteAccount(int retrieve_AccNo)
{
fstream filename;
filename.open("transactions.dat", ios::in);
fstream temp;
temp.open("calculations.txt" , ios::out);
filename.seekg(0,ios::beg);
while ( !filename.eof())
{
filename.read((char*) this, sizeof(accountTransactions));
if (filename.eof())
break;
if ( AccountNumber != retrieve_AccNo)
temp.write((char*) this, sizeof(accountTransactions));
}
filename.close();
temp.close();
filename.open("transactions.dat", ios::out);
temp.open("calculations.txt", ios::in);
temp.seekg(0, ios::beg);
while ( ! temp.eof())
{
temp.read((char*) this, sizeof(accountTransactions));
if (temp.eof())
break;
filename.write((char*) this, sizeof(accountTransactions));
}
filename.close();
temp.close();
}
void accountTrancastion :: new_account(void)
{
char choice;
inti, check;
clrscr();
dispRecords newRec ;
cout<<" Please press 0 to go back to previous menu. \n";
cout<<" \n";
cout<<" ---Open a New Bank Account--- \n";
cout<<" *********************** \n";
int day1,month1,year1;
struch date dateval;
getdate(&dateval);
day1 = dateval.da_day;
month1 = dateval.da_mon;
year1 = dateval.da_year;
int retrieve_AccNo;
retrieve_AccNo = newRec.lastAccount();
retrieve_AccNo++ ;
if (retrieve_AccNo == 1)
{
newRec.addDetails(retrieve_AccNo,"ravi","Delhi",1.1);
newRec.deleteAccount(retrieve_AccNo);
addDetails(retrieve_AccNo,1,1,1997,'D',"default value",1.1,1.1,1.1);
deleteAccount(retrieve_AccNo);
}
xhar retrieve_CustName[30], tran_acc[10], retrieve_Address[60];
float t_bal, iBalance;
cout<<" Date: "<<day1<<"/"<<month1<<"/"<<year1<<"\n";
cout<<" Accout No. # "retrieve_AccNo;
do
{
cout<<"\n\n Please Enter the Name of the Account Holder : ";
check = 1;
gets(retrieve_CustName);
if (retrieve_CustName[0] == '0' )
{
coout<<" \n\t Invalid Customer Name.";
getch();
returen;
}
strupr(retrieve_CustName);
if (strlen(retrieve_CustName) == 0 || strlen(retrieve_CustName) > 30 )
{
check = 0;
cout<<"\t\n Customer Name is either Blank ot it's lenght is greater than 30 characters. \n";
getch();
}
} while (!check);
do
{
cou<<"\n Please Enter the Account Holder's Address : ";
check = 1;
gets(retrieve_Address);
if (retrieve_Address[0] == '0')
{
cout<<"\n\t Invalid Customer Address.";
getch();
return;
}
strupr(retrieve_Address);
if (strlen(retrieve_Address) < 1 || strlen(retrieve_Address) > 60)
{
check = 0;
cout<<"\t\n Customer Address is Either Blank or its length is greater than 60 characters.\n";
getch();
}
}while (!check);
do
{
char chrVerfiyingPerson[30];
cout<<"\n Please Enter the name of the Verifying Person of the Account Holder: ";
check = 1;
gets(chr_VerfiyingPerson);
if (char_VerifyingPerson[0] == '0')
{
cout<<"\n\t Invalid Verfiying Perosn Name. ";
getch();
return;
}
strupr(chr_VerifyingPerson);
if (strlen(chr_VerifyingPerson) < 1 || strlen(chr_VerifyingPerson) > 30)
{
check = 0;
cout<<"\t\n The verifying Person's Name is either blank or greater than 30 characters. Please try again. \n ";
getch();
}
}while (!check);
do
{
cout<<"\n Please Enter the Deposit Amount while opening a New Account :";
check = 1 ;
gets(tran_acc);
iBalance = t_bal;
if (strlen(tran_acc) < 1 ) {
cout<<"\n Invalid Transaction value. Exiting from the current Menu. \n";
getch();
return;
}
if (iBalance < 1000 )
{
check = 0 ;
cout<<"\t\n The Minimum Amount Should be Rs. 1000. Please try again. \n ";
getch();
}
} while (!check) ;
do
{
cout <<"\n Do you want to save the record ? (y/n) : ";
choice = getch();
choice = toupper(choice);
} while (choice != 'N' && choice != 'Y');
if (choice == 'N' || choice =='n')
{
cout<<" \n The Customer Account is not created \n. Please continue wiht the application. \n";
getch();
return;
}
float t_amount, interest_accrued ;
t_amount = iBalance ;
interest_accrued = 0.0 ;
char t_tran, typeTransaction[10] ;
t_tran = 'D' ;
strcpy(typeTransaction," ");
newRec.addDetails(retrieve_AccNo,retrieve_CustName,retrieve_Address,iBalance) ;
addDetails(retrieve_AccNo,day1,month1,year1,t_tran,typeTransaction,interest_accrued,t_amount,iBalance);
cout<<"\n\n The New Account is Successe\fully Created. \n Please continue with this application. \n";
getch();
}
void accountTransactions :: showAccount(int retrieve_AccNo)
{
cout<<"\n"
int day1,month1,year1 ;
struct date dateval;
getdate(&dateval);
day1 = dateval.da_day ;
month1 = dateval.da_mon;
year1 = dateval.da_year;
cout <<" Date : " <<day1 <<"/" << month1 <<"/" << year1 <<"\n" ;
cout <<"Account No. " <<retrieve_AccNo ;
dispRecords newRec ;
char retrieve_CustName[30] ;
strcpy(retrieve_CustName,newRec.getAddress(retrieve_AccNo)) ;
char retrieve_Address[60] ;
strcpy(retrieve_Address,newRec.getAddress(retrieve_AccNo)) ;
cout<<setw(25)<<"\n Account Holder's Name : "<<retrieve_CustName;
cout<<"\Address : "<<retrieve_Address<<"\n";
cout<<setw(80)<<"\n ____________________________________ \n";
cout<<setw(10)<<"Dated";
cout<<setw(12)<<"Details";
cout<<setw(12)<<"Deposited";
cout<<setw(15)<<"Withdrawn";
cout<<setw(12)<<" ";
cout<<setw(10)<<"Balance";
cout<<setw(80)<<"\n ____________________________________ \n";
}
void accountTransactions :: display_account(void)
{
clrscr();
char t_acc[10];
int tran_acc, retrieve_AccNo;
dispRecords obj2;
cout<<" Press 0 to go to the previous menu. \n";
cout<<" Please Enter the Account No. you want to view : " ;
gets(t_acc);
tran_acc = atoi(t_acc);
retireve_AccNo = tran_acc;
if (retrieve_AccNo == 0) {
cout<<"\n You Have Pressed 0 to exit. \n";
getch();
return;
}