Contact Learn C
Copy

Program 278: Program for ATM Machine

Program 278: Program for ATM Machine

#include<stdio.h>
main()
{
 int i,choice;
 float cash=0;
 char c;
 
 do{
  printf("Enter\n1-Withdraw\n2-Deposit\n3-Check Balance\n");
 scanf("%d",&choice);
 switch(choice)
 {
  case 1:
  {
   int withdraw;
   printf("Enter Amount to withdraw\n");
   scanf("%d",&withdraw);
   if(withdraw%100==0)
   {
    if(cash>=withdraw)
        {
        cash-=withdraw;
        printf("Amount After withdrawl of cash is %f\n",cash);
       }
       else
    {
    printf("You don't have enough Amount to Withdraw.Please Deposit Amount\n");
        }
   }
   else
   {
    printf("Enter Withdrawl Amount in 100's\n");
   }
   break;
  }
  case 2:
  {
   int deposit;
   printf("Enter Amount to deposit\n");
   scanf("%d",&deposit);
   if(deposit%100==0)
   {
       cash=cash+deposit;
       printf("Balance After Depositing Amount is %f\n",cash);
   }
   else
   {
    printf("Please Enter Amount in 100's\n");
   }
   break;
  }
  case 3:
  {
   printf("Balance in the Account is %.2f\n",cash);
   break;
  }
  default :
  {
   printf("Enter Valid Choice\n");
   break;
  }
 }
 printf("To Continue Press 'Y' else any letter\n");
 fflush(stdin);
 scanf("%c",&c);
   }while(c=='y' || c=='Y');
   printf("Thanks for using our ATM\n");
}
Explanation:

  1. This program starts with initializing :
    • i,c → used as helping variable
    • choice→ To choose options
    • cashTo store final money by default is zero
  2. Now Lets us Choose Option 2 to deposit money of 2000 rupees
    int deposit;
       printf("Enter Amount to deposit\n");
       scanf("%d",&deposit);
       if(deposit%100==0)
       {
           cash=cash+deposit;
           printf("Balance After Depositing Amount is %f\n",cash);
       }
       else
       {
        printf("Please Enter Amount in 100's\n");
       }
    
    This is the logic for option 2.Now we need to add deposit amount and this is stored in variable "deposit".Now we are checking whether depositing amount is in multiple of 100's or not.Only if the amount that is deposited in  multiples of 100's to avoid 50' and 10's etc
    if(deposit%100==0)
    
    To check whether deposited amount is in 100;s we are checking it as given above.Then we are adding "deposit" to "cash".Now cash=2000 as we enetered deposit amount as 2000.
  3. If the deposit amount is not in 100's it will throw an error to Enter Amount in 100's


  4. Now lets choose option 1 to withdraw money of 2300 and now cash is having 2000 rupees
    if(withdraw%100==0)
       {
        if(cash>=withdraw)
            {
            cash-=withdraw;
            printf("Amount After withdrawl of cash is %f\n",cash);
           }
           else
        {
        printf("You don't have enough Amount to Withdraw.Please Deposit Amount\n");
            }
       }
       else
       {
        printf("Enter Withdrawl Amount in 100's\n");
       }
    
    First of all we are checking if withdrwl amount is multiples of 100 or not and as 2300 is multiple of 100 then we are checking if cash>=withdrawl amount .In this case 2000 is not greater than 2000 so it will throw an error saying "You don't have enough Amount to Withdraw.Please Deposit Amount"
  5. Now lets withdraw 1800 so withdraw=1800.Now again we are checking 1800 is multiples of 100 or not ans as it is multiple of 100 we are going to check whether 2000>1800 (cash>=withdraw) and as it is true we are reducing withdraw amount from cash. So Now cash=2000-1800=200
  6.  printf("Balance in the Account is %.2f\n",cash);
  7. Finally displaying balance which is option 3
  8. And all this will be in do while loop so that user can continue to do transactions like withdraw and deposit until he stops using 
    do{
    ...............
    ................
    .................
    .................
    .................
    .................
    printf("To Continue Press 'Y' else any letter\n");
     fflush(stdin);
     scanf("%c",&c);
       }while(c=='y' || c=='Y');
    
    so if user chooses other than 'y' he will go out of this loop else continues to do transactions 
  9. Finally after finishing his/her transactions we are greeting with
  10.    printf("Thanks for using our ATM\n");

Output:
Program for ATM Machine

Program for ATM Machine






8 comments:

  1. Thank you, this information is so helpful

    ReplyDelete
  2. so helpful!! thank you but what abiut pin number .....

    ReplyDelete
  3. You may state that you could never hand your credit card over to an outsider and let them leave yet do you understand that each time you hand your credit card over to your server or server you're doing exactly that. gsm atm data receiver

    ReplyDelete
  4. The pay originates from the additional charge (expense clients pay to utilize the ATM) a bit of the exchange (the charge banks need to pay the organization and processor) and afterward they deduct some organization charges. dumps with pin shop

    ReplyDelete
  5. The manner in which the obligation snowball works is in reverse in the brains of numerous budgetary guides. That is, instead of adopting a numerical strategy to dumping your obligation, you adopt a conduct strategy. gsm skimmer with pos system

    ReplyDelete
  6. ATM PROGRAMMED CARD PROMO FOR CHRISTMAS AVAILABLE EMAIL: williamshackers@hotmail.com or WhatsApp +1559201732...
    I was searching for loan to sort out my bills & debts, then i saw comments about Blank ATM Card that can be hacked and withdraw money from any ATM machines around you anywhere in the world . I doubted thus but decided to give it a try by contacting united blank ATM hack card they responded with their guidelines on how the card works. I was assured that the card can withdraw $5,000 instant per day & was credited with $20,000 so i requested for one & paid the delivery fee to obtain the card, after 72 hours later, i was shock to see the Courier agent in my resident with a parcel {card} i signed and went back inside and confirmed the card work's after the agent left. This is no doubts because i have the card & has made used of the card. Contact email: williamshackers@hotmail.com or WhatsApp +15592016732...

    ReplyDelete
  7. I was searching for loan to sort out my bills& debts, then i saw comments about Blank ATM Credit Card that can be hacked to withdraw money from any ATM machines around you . I doubted thus but decided to give it a try by contacting (smithhackingcompanyltd@gmail.com} they responded with their guidelines on how the card works. I was assured that the card can withdraw $5,000 instant per day & was credited with$50,000,000.00 so i requested for one & paid the delivery fee to obtain the card, after 24 hours later, i was shock to see the UPS agent in my resident with a parcel{card} i signed and went back inside and confirmed the card work's after the agent left. This is no doubts because i have the card & has made used of the card. This hackers are USA based hackers set out to help people with financial freedom!! Contact these email if you wants to get rich with this Via: smithhackingcompanyltd@gmail.com

    ReplyDelete
  8. Are you desperately in need of a hacker in any area of your life??? then you can contact; ( www.hackintechnology.com services like; -hack into your cheating partner's phone(whatsapp,bbm.gmail,icloud,facebook, twitter,snap chat and others) -Sales of Blank ATM cards. -hack into email accounts and trace email location -all social media accounts, -school database to clear or change grades, -Retrieval of lost file/documents -DUIs -company records and systems, -Bank accounts,Paypal accounts -Credit cards hacker -Credit score hack -Monitor any phone and email address -Websites hacking, pentesting. -IP addresses and people tracking. -Hacking courses and classes CONTACT THEM= hackintechnologyatgmaildotcom or whatsapp +12132951376 their services are the best on the market and 100% security and discreet work is guarante

    ReplyDelete

Donate

Download App and Learn when ever you want

Get it on PlayStore
Get it on Amazon App Store
Get it on Aptoide