ATM Money Withdrawal Algorithm Using C Array
October 21, 2016
October 22, 2016
Hello, friends! We all uses ATM to withdraw money in our daily life. Ever thought how it is work behind ATM. As per Wikipedia Cash Machine is the origin name of ATM (automated teller machine) also it called ABM (automated banking machine). It is the combination of electromechanical hardware and software. Actually, most of ATM are programmed with JAVA behind it, but here we implement algorithm only withdrawal functionality using C-Array.
C ATM Money Withdrawal Algorithm:
#include<stdio.h> void main() { int money[]={1000,500,100,50,20,10,5,2,1}; //money to disbursed int withdraw_amt=0; //For store withdrawl amount int i=0,r; clrscr(); printf(" Enter An Amount to Withdrawal : "); scanf("%d",&withdraw_amt); while(withdraw_amt >0) { r=withdraw_amt/money[i]; // Withdrawl amount devided by each money sets on above withdraw_amt= withdraw_amt%money[i]; //a reminder will set again withdrawal amount. printf(" Please Collect note of %4d rupees : %4d \n",money[i],r); i++; } printf(" THANKS FOR USING OUR ATM SERVICE "); getch(); }
Output:
So, The above program shows only how the money will be disbursed. Here I use cent also, usually the cent and coin not use in the ATM machines.
The following two tabs change content below.
Subroto Mondal
Chief Coordinator HR&CR
I like Programming and New Technologies. And work with Linux.
Latest posts by Subroto Mondal (see all)
- Installing and Configuring OpenShift: A Step-by-Step Guide for Linux Experts with Terminal Code - February 19, 2023
- Sed Command in Linux with Practical Examples - February 19, 2023
- Rsync Command uses with examples - February 19, 2023
#include
#include
main()
{
int choice,choice2;
float withd, depo,bal;
bal=0;
withd=0;
depo=0;
clrscr();
do
{
clrscr();
printf(“**********Da.Bank***********\n”);
printf(“*****************************\n\n”);
printf(“1. Deposit\n”);
printf(“2. Withdraw \n”);
printf(“3. Balance inquiry \n”);
printf(“4. Fast cash \n”);
printf(“5. Exit\n”);
printf(“\nenter choice:”);
scanf(“%d”,&choice);
switch(choice)
{
case 1: printf(“\n\n\nDEPOSIT MENU”);
printf(“\n***************”);
printf(“\nplease enter deposit amount:”);
scanf(” %f”,&depo);
if(depo > 0 )
{
bal = bal + depo;
printf(“\nyou have deposited %.2f”,depo);
printf(“\nyour new acount balance is %.2f\n\npress any key to continue:”,bal);
}
else
{
printf(“\nerror:you can not deposit less than 0” );
printf(“\n\n\npress any key to continue:”);
}
break;
case 2: printf(“\nWITHDRAW MENU”);
printf(“\n*****************************”);
printf(“\nyour current ballance is %.2f”,bal);
printf(“\nplease enter withdraw amount:”);
scanf(” %f”,&withd);
if(withd = 0)
{
bal = bal – withd;
printf(“\nyou have withdrawn %.2f \nyour curent ballance is %d”,withd,bal);
}
else
{
printf(“\nerror: you have insuficient”);
}
printf(“\npress any key to continue:”);
break;
case 3: printf(“\nBALANCE INQUIRY MENU”);
printf(“\nyour account balance is %.2f”,bal);
printf(“\npress any key to continue:”);
break;
case 4: printf(“\nFAST CASH MENU”);
printf(“\n*****************************”);
printf(“\nFast cash options\n1. 100\n2. 200\n3. 500\n4. 1000”);
printf(“\nenter choice:”);
scanf(“%d”,&choice2);
switch(choice2)
{ case 1: if(bal > 100)
{ bal = bal – 100;
withd = 100;
printf(“\nyou have withdrawn %.2f\n your curent balance is .%2f”,withd,bal);
}
else
{
printf(“\ninsuficient funds for this transaction”);
}
printf(“\npress any key to continue:”);
break;
case 2: if(bal > 200)
{ bal= bal – 200;
withd=200;
printf(“\nyou have withdrawn %.2f\n your curent balance is .%2f”,withd,bal);
}
else
{
printf(“\ninsuficient funds for this transaction”);
}
printf(“\npress any key to continue:”);
break;
case 3: if(bal > 500)
{ bal = bal – 500;
withd = 500;
printf(“\nyou have withdrawn %.2f\n your curent balance is .%2f”,withd,bal);
}
else
{
printf(“\ninsuficient funds for this transaction”);
}
printf(“press any key to continue:”);
break;
case 4: if(bal > 1000)
{ bal = bal – 1000;
withd = 1000;
printf(“you have withdrawn %.2f\n your curent balance is .%2f”,withd,bal);
}
else
{
printf(“insuficient funds for this transaction”);
}
printf(“press any key to continue:”);
break;
}
break;
case 5: printf(“thank you for using this ATM, gudbye”);
break;
default: printf(“error, please sellect from the give options”);
break;
}
}while(choice != 5);
getch();
}