
| Turbo C - ATM Program |
|
#include<stdio.h> #include<conio.h> #include<dos.h> /* Programmed by Harvey Losin */ /* http://www.bikoy.com/harvey */ /* webmaster@bikoy.com */ main() { char ch,option, exit_option; float pin1, pin2, pin3, pin4, pin5; float bal1, bal2, bal3, bal4, bal5; float pin, amnt_deposit, amnt_wthdrw, balance; repeat1: clrscr(); gotoxy(31,2); printf("==================="); gotoxy(31,3); printf("= ATM MACHINE ="); gotoxy(31,4); printf("==================="); gotoxy(7,23); printf("GRP9 : SY2002-2003 1st Sem Midterm : COME211 M-F 8:45-9:45 Ms. Mari"); gotoxy(35,12); printf("enter PIN: "); scanf("%f",&pin); pin1=11111; bal1=0.00; pin2=22222; bal2=0.00; pin3=33333; bal3=0.00; pin4=44444; bal4=0.00; pin5=55555; bal5=0.00; balance=0; { if(pin==pin1 || pin==pin2 || pin==pin3 || pin==pin4 || pin==pin5) { gotoxy(30,12); printf("*** PIN accepted! ***"); delay(100); delay(100); goto menu_deposit; } else { gotoxy(20,12); printf("*** Invalid PIN! Please try again... ***"); getch(); goto repeat1; } } menu: { clrscr(); gotoxy(28,7); printf(" Pick-A-Choice:"); gotoxy(28,8); printf(" [1] Deposit"); gotoxy(28,9); printf(" [2] Withdraw"); gotoxy(28,10); printf(" [3] Inquire"); gotoxy(28,11); printf(" [4] Exit"); gotoxy(28,12); printf(" choice: "); option=getche(); switch(option) { case '1': { menu_deposit: clrscr(); gotoxy(34,2); printf("[ DEPOSIT ]"); gotoxy(22,9); printf("how much would you like to deposit?"); gotoxy(22,10); printf("amount: P"); scanf("%f",&amnt_deposit); balance=balance+amnt_deposit; delay(100); delay(100); gotoxy(22,12); printf("Deposit confirmed!!!"); delay(100); delay(100); gotoxy(22,12); printf("P%.2f was added to your account.",amnt_deposit); delay(100); gotoxy(22,17); printf("Press any key to proceed..."); getch(); goto menu; } case '2': { rewthdrw: clrscr(); gotoxy(34,2); printf("[ WITHDRAWAL ]"); gotoxy(22,6); printf("How much would you like to withdraw?"); gotoxy(22,7); printf("amount: P"); scanf("%f",&amnt_wthdrw); if(amnt_wthdrw>balance) { delay(100); gotoxy(22,9); printf("Sorry, but you you have insufficient funds in your account."); getch(); goto rewthdrw; } if(amnt_wthdrw<100) { delay(100); gotoxy(22,9); printf("This machine does not allow withdrawals less than P100."); getch(); goto rewthdrw; } balance=balance-amnt_wthdrw; gotoxy(22,9); printf("Transaction in progress..."); delay(100); delay(100); delay(100); gotoxy(22,9); printf("Get you cash and transaction slip..."); delay(100); delay(100); delay(100); gotoxy(22,11); printf("Thank you for banking with us!"); delay(100); gotoxy(22,15); printf("Press any key to proceed..."); getch(); goto menu; } case '3': { clrscr(); gotoxy(28,2); printf("[ BALANCE INQUIRY ]"); gotoxy(22,9); printf("Transaction in progress..."); delay(100); delay(100); delay(100); gotoxy(22,9); printf("Your account balance: P%.2f",balance); gotoxy(22,13); printf("Press any key to proceed..."); getch(); goto menu; } case '4': { turbo: clrscr(); gotoxy(26,10); printf("Want another Transaction?"); gotoxy(27,11); printf("Enter another [P]IN."); gotoxy(27,12); printf("[E]ND Transaction."); ch=getch(); if(ch=='p'||ch=='P') { menu_pin: clrscr(); { if(pin==pin1) { bal1=balance; } if(pin==pin2) { bal2=balance; } if(pin==pin3) { bal3=balance; } if(pin==pin4) { bal4=balance; } if(pin==pin5) { bal5=balance; } } gotoxy(30,2); printf("[ ENTER ANOTHER PIN ]"); gotoxy(30,12); printf("Enter new PIN: "); scanf("%f",&pin); { if(pin==pin1) { balance=bal1; goto menu; |