Program WisarutATM;
Uses Wincrt;
Var pw,mycode,mycode2,mycredit,cusdrw:Integer;
myname:String;
Const mypw=1234;
Procedure EnterPWD(var pw:integer);
begin
clrscr;
Write('Enter password : '); Readln(pw);
If pw=mypw Then
begin
clrscr;
writeln('**Correct password**':20);
write('Press Enter to continue...'); readln;
end
Else
begin
clrscr;
writeln('Incorrect password!');
write('Try again[2] : '); readln(pw);
if pw=mypw then
begin
clrscr;
writeln('**Correct password**':20);
write('Press Enter to continue...'); readln;
end
else
begin
clrscr;
writeln('Incorrect password!');;
write('Try again[3] : '); readln(pw);
if pw=mypw then
begin
clrscr;
writeln('**Correct password**':20);
write('Press Enter to continue...'); readln;
end
else
begin
clrscr;
writeln('Incorrect password!');
writeln('Please contact the bank.');
end;
end;
end;
end;
Procedure MenuChkCredit;
begin
clrscr;
write('Account Name : '); readln(myname);
write('Balance : '); readln(mycredit);
end;
Procedure Mainmenu(var mychk:integer);
begin
clrscr;
writeln('**{[[[ MAINMENU ]]]}**':42);
gotoxy(3,3); write('[1] <<-Select 1 for Deposit');
gotoxy(38,3); write('Select 2 for Withdrawal ->> [2]');
gotoxy(3,5); write('[3] <<-Select 3 for Cancel');
gotoxy(32,7); write(']');
gotoxy(30,7); write('['); readln(mychk);
end;
Procedure Menu1;
var sal:integer;
begin
clrscr;
writeln('**{[[[ Deposit ]]]}**':20);
write('Insert *** = '); readln(sal);
if sal < 0 then
begin
writeln('Cannot deposit (-)number!');
write('Press Enter to continue...');
readln;
end
else
begin
mycredit:=mycredit+sal;
writeln('Current balance = ',mycredit);
write('Press Enter to Mainmenu...'); readln;
end;
end;
Procedure MenuWithdraw(var mychk2:integer);
begin
clrscr;
writeln('**{[[ Withdrawal ]]}**':42);
gotoxy(3,3); write('[1] <<- Withdraw 500 Baht');
gotoxy(35,3); write('[2] <<- Withdraw 1000 Baht');
gotoxy(3,5); write('[3] <<- Withdraw 5,000 Baht');
gotoxy(35,5); write('[4] <<- Withdraw 10,000 Baht');
gotoxy(3,7); write('[5] <<- Withdraw 20,000 Baht');
gotoxy(35,7); write('[6] <<- Customize Withdraw');
gotoxy(3,9); write('Select and Press Enter ->>');
gotoxy(37,9); write(']'); gotoxy(35,9); write('['); readln(mychk2);
end;
Procedure ShowDraw(drw:integer);
begin
clrscr;
writeln('** Withdrawal Information **');
gotoxy(3,3); writeln('Withdraw = ',drw);
gotoxy(3,5); writeln('Curren Balance = ',mycredit);
gotoxy(1,7); write('Press enter to continue...');
readln;
end;
Procedure OverCredit(ovr:integer);
begin
clrscr;
writeln('Cannot withdraw ',ovr);
writeln('Because Balance = ',mycredit);
write('Press Enter to Mainmenu...');
readln;
end;
Procedure CusDraw(var cusdrw:integer);
begin
clrscr;
writeln('** Customize Withdraw **');
gotoxy(3,3); write('Insert *** = '); readln(cusdrw);
end;
Begin
EnterPWD(pw);
If pw<>mypw Then
readln
else
MenuChkCredit;
While pw=mypw do
begin
Mainmenu(mycode);
If mycode=1 Then
Menu1
Else If mycode=2 Then
begin
MenuWithdraw(mycode2);
If mycode2=1 Then
begin
if 500 > mycredit then
OverCredit(500)
else
begin
mycredit:=mycredit-500;
ShowDraw(500);
end;
end
else if mycode2=2 then
begin
if 1000 > mycredit then
OverCredit(1000)
else
begin
mycredit:=mycredit-1000;
ShowDraw(1000);
end;
end
else if mycode2=3 then
begin
if 5000 > mycredit then
OverCredit(5000)
else
begin
mycredit:=mycredit-5000;
ShowDraw(5000);
end;
end
else if mycode2=4 then
begin
if 10000 > mycredit then
OverCredit(10000)
else
begin
mycredit:=mycredit-10000;
ShowDraw(10000);
end;
end
else if mycode2=5 then
begin
if 20000 > mycredit then
OverCredit(20000)
else
begin
mycredit:=mycredit-20000;
ShowDraw(20000);
end;
end
else if mycode2=6 then
begin
CusDraw(cusdrw);
if cusdrw <0 then
begin
writeln('Cannot withdraw (-)number');
write('Press enter to continue...'); readln;
end
else
begin
if cusdrw > mycredit then
OverCredit(cusdrw)
else
begin
mycredit:=mycredit-cusdrw;
ShowDraw(cusdrw);
end;
end;
end
else
begin
writeln('No selected menu!');
write('Press enter to continue...'); readln;
end;
end
Else If mycode=3 Then
EnterPWD(pw)
Else
begin
Writeln('No selected menu!');
Write('Press Enter to Mainmenu...'); Readln;
end;
end;
End.
******************************************************************
จบคับ.....................
มาจากที่นี่ครับ
ส่วนคำอธิบาย ต้องรบกวนแอทมินแล้วละคับ ใช้ได้ไม่ได้ก้ออย่าว่ากันนะคคับ มือไหม่เหมือนัน