TASK-
ATM Machine
Develop a C-Code for the implementation of ATM machine with the following features:
- Have a name of your bank. Make an account of a dummy client with an initial amount of Rs.250,000 and a 4 digit PIN (5678).
- Your code should first of all say Welcome to the client.
- Your code then should ask the client to enter the 4-digit PIN. Check the PIN. If it is incorrect, ask the client again to re-enter the PIN. Allow the client to enter the PIN for maximum three times only. For 3rd incorrect entry, display the message “Your card is captured. Please contact the Bank Manager”, and the program should be terminated.
- If correct PIN is entered (within maximum three attempts), your code should display the following main menu.
- Balance Enquiry
- Cash Withdrawal
- Cash Deposit
- Change PIN
- Exit
For Further Detail about the task click here: 👉👉 ATM MACHINE
CODE:
#include<stdio.h>
#include<stdlib.h>
Int main ()
{
//Validity check
Int pin,entered_pin,intial_amount,count=1;
int new_pin1,new_pin2,_new_pin3,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;
Expected Output for Validity
Case 1: When all Tries are fail!
//MAIN MENU
int
ext=0,opt,amount,amount2=25000;
int ext2=0,amount3,amount4=90000,ext3=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'&&s=='a')
continue;
else if(s=='B'&&s=='b')
ext=1;
Expected Output for Balance enquiry + Repeat Option:
// 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'&&opt2=='y')
{
continue;
}
else if (opt2=='N'&&opt2=='n')
break;
}
}
printf("Press
A to return to main menu or enter B to Exit\n");
scanf("%s",&s);
if (s=='A'&&s=='a')
continue;
else if(s=='B'&&s=='b')
ext=1;
Expected Outputs For Cash Withdrawal:
//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'&&opt=='y')
{
continue;
}
else if (opt2=='N'&&opt2=='n')
break;
}
}
printf("Press A to return to main menu or
enter B to Exit\n");
scanf("%s",&s);
if (s=='A'&&s=='a')
continue;
else if(s=='B'&&s=='b')
ext=1;
Expected Outputs For Cash deposit:
//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);
// condition to repeat the procedure
if (s=='A' && s=='a')
continue;
else if(s=='B' && s=='b')
ext=1;
Expected Outputs For pin change:
//Exit
case 5:
printf("Thanks,
Allah Hafiz, Please Take Your Card");
exit(0);
}
Expected Outputs For Exit:
}
getchar();
return 0;
}
Very nice Sir g
ReplyDeleteI helped me a lot bro
ReplyDeleteAmazing Work Brother also post an atm with functions.
ReplyDeleteComing soon with ATM by functions
DeleteGreat bro amazing information 👍👍👍👍👍👍👍👍👍
ReplyDelete