123 Eng

Engineering the engineers™


Latest Jobs   Forum Map

 


Home
Source Codes
Engineering Colleges

Training  Reports
Seminar Reports
Placement Papers

Forums

   Computer Science / IT
   Electronics
   Electrical
   Mechanical
   Chemical
   Civil

   CAT / MBA

   GMAT / Foreign MBA
Latest Jobs

Engineering Jobs / Technical Jobs
Management Jobs

Sitemap
Terms of use

Displaying  Source Code(s)  
 

 
Program that stores Bank account holder data in file.

--------------------------------------------------------------------------------



{
Description: Program that stores account holder data in file
}
program bank_acount;

{Program that stores account holder data in file
NOTE: make a txt file with name 'acc_file.txt' in the folder before
running this code}


uses crt;

type
name= record
first :string;
second:string;
last :string;
end;

address = record
flat :string;
block :string;
postal :string;
city :string;
province:string;
country :string;
end;

apointer=^acount;
Acount = record
ano :real;
aname :name;
aaddress:address;
credit:real;
next:apointer
end;

acountfile=file of acount;


var
head,tail,temp :apointer;
accountno: real;
acount_choice:char;
check:boolean;
afile:acountfile;
data:acount;
{============================================================================}

{ ERROR MSGS
}
{============================================================================}


PROCEDURE ERROR_MSG;
BEGIN
textcolor(lightred + blink);
writeln;writeln;
writeln('INCORRET NUMBER ENTERED !');
textcolor(15);
writeln('Press any key to continue...');
readkey;
END;

PROCEDURE CHECK_NO(p:apointer;no:real);
begin
check:=false;

while p<> nil do
begin
if P^.ano = no then
check:=true;
p:=p^.next;
end;

end;


{============================================================================}

{ TRANSFER MONEY
}
{============================================================================}


PROCEDURE TRANSFER(p:apointer);
var
q,r:apointer;
ano1,ano2,money: real;
ch:char;
check:boolean;
BEGIN
q:=p;

repeat
begin
clrscr;
writeln;
WRITeln('M O N E Y T R A N S F E R':50);
writeln('=============================':50);
writeln;
check:=false;
write('Enter the account number from which the money is to be
transfer > ');
readln(ano1);

while p<>nil do
begin
if p^.ano=ano1 then
begin
r:=p;
check:=true
end;
p:=p^.next;
end;
p:=q;

if check =false then
begin
writeln('Account not found');
writeln('Press ENTER to enter agian or any other key to exit');
ch:=readkey;
if ord(ch)<>13 then
exit;
end;
end;
until check=true;
check:=false;

repeat
begin
clrscr;
gotoxy(1,2);
WRITeln('M O N E Y T R A N S F E R':50);
writeln('=============================':50);
gotoxy(1,5);
write('Enter the account number from which the money is to be
transfer > ' ,ano1:1:0);
writeln;
write('Enter the account number to which the money is to be
transfer > ');
readln(ano2);
p:=head;
while p<>nil do
begin
if p^.ano=ano2 then
begin
q:=p;
check:=true
end;

p:=p^.next;
end;

if check =false then
begin
writeln('Account not found');
writeln('Press ENTER to enter agian or any other key to
exit');
ch:=readkey;
if ord(ch)<>13 then
exit;
end;
end;
until check=true;


write('Enter the amount to be transfer >' );
readln(money);

if money > (r^.credit-1000) then
begin
writeln('not enough money to be transfer') ;
writeln('press any key to return to main menu');
readkey;
end
else
begin
r^.credit:=r^.credit-money;
q^.credit:=q^.credit+money;
end;

end;



{============================================================================}

{ SEARCH ACCOUNT
}
{============================================================================}


PROCEDURE SEARCH( p:apointer);
var
fname,lname,postal,city: string;
count:integer;
no:real ;
find:char;
procedure print_search(p:apointer);
begin
write('SEARCH NO. > ');
writeln(count);
write('ACCOUNT NUMBER > ');
writeln(p^.ano:1:0);
write('ACCOUNT CREDIT > ');
writeln(p^.credit:1:0);
write('ACCOUNT HOLDER NAME > ');
write(p^.aname.first);
write(' ',p^.aname.second);
writeln(' ',p^.aname.last);
write('ACCOUNT HOLDER ADDRESS > ');
write('Flat:',p^.aaddress.flat);
write(', Block:',p^.aaddress.block);
write(', ',p^.aaddress.city);
write(', ',p^.aaddress.province);
write(', ',p^.aaddress.country);
writeln(', ',p^.aaddress.postal);
writeln;
end;

BEGIN

clrscr;
count:=0;
writeln('S E A R C H A C C O U N T':40);
writeln;
Writeln('1) Search by account numbere ');
Writeln('2) Search by first name');
Writeln('3) Search by last name ');
Writeln('4) Search by postal code');
Writeln('5) Search by city');
Writeln('6) Exit');
writeln;
write('Enter the search criteria > ');
readln(find);
case find of

'1': BEGIN
clrscr;
write('Enter the Account Number > ');
readln(no);
while p<> nil do
begin
if no = p^.ano then
begin
count:=count+1;
print_search(p);
if count mod 3 = 0 then
begin
writeln('Press any key to continue..');
readkey;
end;
end;
p:= p^.next;
end;
END;

'2': BEGIN
clrscr;
write('Enter the first name > ');
readln(fname);
while p<> nil do
begin
if fname = p^.aname.first then
begin
count:=count+1;
print_search(p);
if count mod 3 =0 then
begin
writeln('Press any key to continue..');
readkey;
end;
end;
p:= p^.next;
end;
END;

'3': BEGIN
clrscr;
write('Enter the last name > ');
readln(lname);
while p<> nil do
begin
if lname = p^.aname.last then
begin
count:=count+1;
print_search(p);
if count mod 3=0 then
begin
writeln('Press any key to continue..');
readkey;
end;
end;
p:= p^.next;
end;
END;

'4': BEGIN
clrscr;
write('Enter the Postal Code > ');
readln(postal);
while p<> nil do
begin
if postal = p^.aaddress.postal then
begin
count:=count+1;
print_search(p);
if count mod 3 =0 then
begin
writeln('Press any key to continue..');
readkey;
end;
end;
p:= p^.next;
end;
END;

'5': BEGIN
clrscr;
write('Enter the city name > ');
readln(city);
while p<> nil do
begin
if city = p^.aaddress.city then
begin
count:=count+1;
print_search(p);
if count mod 3 =0 then
begin
writeln('Press any key to continue..');
readkey;
end;
end;
p:= p^.next;
end;
END;

'6': BEGIN
exit;
END;

else
BEGIN
error_msg;
END;
END;{case}

if ((find='1') or(find='2') or(find='3') or
(find='4') or(find='5') or(find='6')) and (count = 0) then
writeln('Name not found');

if ((find='1') or(find='2') or(find='3') or
(find='4') or(find='5') or(find='6') )and((count mod 3
<> 0) or( count=0))then
begin
writeln('Press any key to continue...');
readkey;
end;
search(head);
end;

{============================================================================}

{ CLOSED ACCOUNT
}
{============================================================================}


PROCEDURE Close(p:apointer);
var
r: apointer;
no : real ;
count:integer;
BEGIN
count:=0;
clrscr;
writeln;
WRITE('Enter ACCOUNT NO. to close the account > ');
readln(no);

while p<> nil do
begin
if no = p^.next^.ano then
begin
r:= p^.next;
p^.next:=p^.next^.next;
r^.next:=nil;
dispose (r);
count:=1;
end;
p:= p^.next;
end;

if head^.ano = no then
begin
r:= head;
head:=head^.next;
r^.next:=nil;
dispose (r);
count:=1;
end;



if count=0 then writeln('Account not found') else
Writeln('Record of ',no:10:0,' deleted');
writeln('Press any key to continue...');
readkey;
END;

{============================================================================}

{ READ DATA INTO ACCOUNT
}
{============================================================================}


PROCEDURE READ_DATA(p: apointer);
BEGIN
accountno :=8876543;

repeat
begin
accountno:=accountno+1;
check_no(head,accountno);
end;
until check=false;
p^.ano:=accountno;

repeat
clrscr;

textcolor(11);
writeln('ACCOUNT INFO');
writeln('--------------');
textcolor(15);

writeln('Account No. > ',p^.ano:1:0 );
write ('Account credit > ');
readln(P^.credit);
gotoxy(1,4);
writeln('Account credit > ' ,p^.credit:1:0);

if P^.credit<1000 then
begin
writeln('Minimun acount limit is Rs.1000');
writeln('Press any key to enter again..');
readkey;
end;

until P^.credit>=1000;

writeln;
textcolor(11);
writeln('ACCOUNT HOLDER NAME');
writeln('-------------------');
textcolor(15);

repeat
gotoxy(1,8);
write('Enter the first name >');
readln(p^.aname.first);
until length (p^.aname.first)>0;

repeat
gotoxy(1,9);
write('Enter the second name >');
readln(p^.aname.second);
until length (p^.aname.second)>0;

repeat
gotoxy(1,10);
write('Enter the last name >');
readln(p^.aname.last);
until length (p^.aname.last)>0;

writeln;
textcolor(11);
writeln('ACCOUNT HOLDER ADDRESS');
writeln('----------------------');
textcolor(15);

repeat
gotoxy(1,14);
write('Enter the Plot no./Flat no./House no. >');
readln(p^.aaddress.flat);
until length (p^.aaddress.flat)>0;

repeat
gotoxy(1,15);
write('Enter the Street no./Block no. >');
readln(p^.aaddress.block);
until length (p^.aaddress.block)>0;

repeat
gotoxy(1,16);
write('Enter the Postal Code >');
readln(p^.aaddress.postal);
until length (p^.aaddress.postal)>0;

repeat
gotoxy(1,17);
write('Enter the City >');
readln(p^.aaddress.city);
until length (p^.aaddress.city)>0;

repeat
gotoxy(1,18);
write('Enter the Province >');
readln(p^.aaddress.Province);
until length (p^.aaddress.province)>0;

repeat
gotoxy(1,19);
write('Enter the Country >');
readln(p^.aaddress.country);
until length (p^.aaddress.country)>0;
writeln;
writeln('Data input completed!');
writeln('press any key to return to menu');
readkey;
END;
{============================================================================}

{ MAKE FILE
}
{============================================================================}

PROCEDURE CREATE_FILE(P:APOINTER) ;
BEGIN
rewrite(afile);
while p<>nil do
begin
data:=p^;
write(afile,data);
p:=p^.next;
end;

END;


{============================================================================}

{ READ FORM FILE
}
{============================================================================}


PROCEDURE READ_FILE(TEMP:APOINTER;DATA:ACOUNT);
BEGIN
temp^.ano:=data.ano;
temp^.aname.first :=data.aname.first
;
temp^.aname.second :=data.aname.second
;
temp^.aname.last :=data.aname.last
;
temp^.aaddress.flat :=data.aaddress.flat
;
temp^.aaddress.block :=data.aaddress.block
;
temp^.aaddress.postal :=data. aaddress.postal
;
temp^.aaddress.city :=data.aaddress.city
;
temp^.aaddress.province :=data.aaddress.province
;
temp^.aaddress.country :=data.aaddress.country
;
temp^.credit:= data.credit
;
END;
{============================================================================}

{ OPEN ACCOUNT
}
{============================================================================}


PROCEDURE INSERT_ACCOUNT;
BEGIN

if head = nil then
begin
new(temp);
read_data(temp);
head:=temp;
head^.next:=nil;
end

else
begin
new(temp);
read_data(temp);
temp^.next:=head;
head:=temp;
end
end;

{============================================================================}

{ MAIN MENU
}
{============================================================================}


PROCEDURE Account_option;
var
select : char;
begin

clrscr;

textcolor(9);
writeln;
writeln('ACOUNT OPTIONS':40);
writeln;
textcolor(15);
writeln('1) OPEN ACCOUNT':41);
writeln;
writeln('2) CLOSED ACCOUNT':43);
writeln;
writeln('3) TRANSFER MONEY':43);
writeln;
writeln('4) SEARCH':35);
writeln;
writeln('5) EXIT':33);

writeln;writeln;
textcolor(7);
write('ENTER THE OPTION FROM THE ABOVE MENU >');
readln(acount_choice);

case acount_choice of
'1': begin
gotoxy(1,4);
textcolor(11+blink);
writeln('1) OPEN ACCOUNT':41);
gotoxy(41,17);
delay(1500);
textcolor(15);
insert_account;
Account_option;
end;
'2': begin
gotoxy(1,6);
textcolor(11+blink);
writeln('2) CLOSED ACCOUNT':43);
gotoxy(41,17);
delay(1500);
textcolor(15);
close(head);
Account_option;
end;

'3': begin
gotoxy(1,8);
textcolor(11+blink);
writeln('3) TRANSFER MONEY':43);
gotoxy(41,17);
delay(1500);
textcolor(15);
transfer(head);
Account_option;
end;

'4': begin
gotoxy(1,10);
textcolor(11+blink);
writeln('4) SEARCH':35);
gotoxy(41,17);
delay(1500);
textcolor(15);
search(head);
Account_option;
end;

'5': begin
gotoxy(1,12);
textcolor(11+blink);
writeln('5) EXIT':33);
gotoxy(41,17);
delay(500);
create_file(head);
exit;
end;

else
begin ERROR_MSG; Account_option; end;

end;

end;
{============================================================================}

{ END OF PROCEDURES
}
{============================================================================}


BEGIN
clrscr;
accountno :=8876543;
window(1,1,80,3);
textcolor(11);
writeln('B A N K A C C O U N T S':54);
writeln('=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=':54);
window(1,3,80,25);

assign(afile,'acc_file.txt');
reset(afile);
while not eof(afile) do
begin
if head = nil then
begin
new(temp);
read(afile,data);
READ_FILE (TEMP,DATA);
head:=temp;
head^.next:=nil;
end

else
begin
new(temp);
read(afile,data);
READ_FILE (TEMP,DATA);
temp^.next:=head;
head:=temp;
end
end;
Account_option;
END.

 

 

Contribute content or training reports / feedback / Comments
job placement papers
All rights reserved copyright 123ENG