You are on page 1of 14

Lab Project

ATM PROGRAM

LAB PROJECT: 01
Department: CIS
Name: Abdul Rehman
Serial Number: 02
Date of submission: 21/nov/2021
CODE:
#include<stdio.h>
#include<stdlib.h>
Int main () {
//Validity check
Int
pin,entered_pin,intial_amount,count=1,new_pin1,new_pin2,_new_pin
3,old_pin;
pin=5678;
intial_amount=250000;
printf("\t\tMUSLIM BANK\n");
printf("*WELCOME*\n");
while (entered_pin!=pin)
{
printf("\nEnter your Pin\n");
scanf("%d",&entered_pin);
if (entered_pin!=pin && count!=3)
printf("\nInvalid try again!\n");
if (count==3 && entered_pin!=pin )
{
printf("Your card is captured. Please contact the Bank
Manager");
exit(0);
}
count++;
}
//validity check over;
//MAIN MENU
int
ext=0,opt,amount,amount2=25000,ext2=0,amount3,amount4=90000,e
xt3=0,ext4=0,ext5=0;
char s,opt2;
while (ext!=1)
{
printf("\t\tPlease select the option\n");
printf("1) Balance Enquiry\n2) Cash Withdrawal\n3) Cash
Deposit\n4) Change PIN\n5) Exit\n");
scanf("%d",&opt);
switch(opt)
{
//balance enquiry
case 1:
printf("Your current balance is %d\n",intial_amount);
printf("Press A to return to main menu or enter B to
Exit\n");
scanf("%s",&s);
if (s=='A')
continue;
else if(s=='B')
ext=1;
// cash withdraw
case 2:
while (ext2!=2){

printf("Enter an amount \n");


scanf("%d",&amount);
if (amount>intial_amount)
{
printf("you don't have enough money\n");
break;
}
else if (amount>amount2 )
{
printf("Entered amount is greater than 25000\n");
continue;
}
else if (amount%500!=0)
{
printf("Entered amount is not a multiple of 500\
n");
continue;
}
else
{
intial_amount=intial_amount-amount;
printf("Please take your amount %d\n",amount);
printf("Your current balance = %d\n",intial_amount);
printf("Do you want more Withdrawal Transaction? Press Y
for Yes or N for No\n");
scanf("%s",&opt2);
if (opt2=='Y')
{
continue;
}
else if (opt2=='N')
break;
}
}
printf("Press A to return to main menu or enter B to Exit\n");
scanf("%s",&s);
if (s=='A')
continue;
else if(s=='B')
ext=1;
//CASH DEPOSITE
case 3:
while (ext3!=3)
{
printf("Enter an amount\n");
scanf("%d",&amount3);
if (amount3>amount4)
{
printf("Entered amount is greater then %d\
n",amount4);
continue;
}
else if (amount3%500!=0)
{
printf("Entered amount should be multiple of
500\n");
continue;
}
else
{
intial_amount=intial_amount+amount3;
printf("Your amount has been deposited\n");
printf("Your current balance = %d\n",intial_amount);
printf("Do you want more Deposite Transaction? Press Y for
Yes or N for No\n");
scanf("%s",&opt2);
if (opt2=='Y')
{
continue;
}
else if (opt2=='N')
break;
}
}
printf("Press A to return to main menu or enter B to Exit\
n");
scanf("%s",&s);
if (s=='A')
continue;
else if(s=='B')
ext=1;
//Pin change
case 4:
while (ext4=4)
{
printf("Enter old pin\n");
scanf("%d",&old_pin);
if (old_pin!=pin)
{
printf("Invalid try again\n");
continue;
}
else
{
printf("Enter new pin\n");
scanf("%d",&new_pin1);
while (ext5=5)
{
printf("Enter new pin again \n");
scanf("%d",&new_pin2);
if (new_pin2!=new_pin1)
{
printf("Error!!! Enter second pin
again\n");
continue;
}
else
{
pin=new_pin1;
printf("Pin changed successfully\n");
break;
}

}
}
break;
}
printf("Press A to return to main menu or enter B to
Exit\n");
scanf("%s",&s);
if (s=='A')
continue;
else if(s=='B')
ext=1;
//Exit
case 5:
printf("Thanks, Allah Hafiz, Please Take Your
Card");
exit(0);
}

}
getchar();
return 0;
}
OUTPUT for Pin Validity:
Case 1: When all Tries are fail!

Case 2:
Pin correctly entered after 2 tries and main menu is shown:
OUTPUT for balance enquiry + Repeat option;
OUTPUT for cash withdrawal:
OUTPUT for Cash deposit;
OUTPUT for Pin Change;

OUTPUT for Exit;

You might also like