SET OF PROGRAMS

This blog provided "C" programs for beginners. Providing c programs for students.enjoy this blog.this blog include many c programs for engineering students, IT engineering students and programmers this blog is very useful.this blog post daily 1-5 programs for you.this programs use full for devlop games devlops application and much more. This blog programs useful for projects because all programs post with explanations.

Search Bar

Ads Here

Monday, 25 June 2018

C program for ATM Machine


Read This Program Click Here๐Ÿ‘†๐Ÿ‘†
This program is application of ATM machine.ATM machine c program given below.This Program Shows ATM MACHINE
Transmission And Working let's You Enjoy This Program

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");
}
Output:
Enter
1-Withdraw
2-Deposit
3-Check Balance
1
Enter Amount to withdraw
120
Enter Withdrawl Amount in 100's
To Continue Press 'Y' else any letter
Y
Enter
1-Withdraw
2-Deposit
3-Check Balance
2
Enter Amount to deposit
1200
Balance After Depositing Amount is 1200.000000
To Continue Press 'Y' else any letter
Y
Enter
1-Withdraw
2-Deposit
3-Check Balance
1
Enter Amount to withdraw
1250
Enter Withdrawl Amount in 100's
To Continue Press 'Y' else any letter
Y
Enter
1-Withdraw
2-Deposit
3-Check Balance
1
Enter Amount to withdraw
300
Amount After withdrawl of cash is 900.000000
To Continue Press 'Y' else any letter
Y
Enter
1-Withdraw
2-Deposit
3-Check Balance
3
Balance in the Account is 900.00
To Continue Press 'Y' else any letter
Y
Enter
1-Withdraw
2-Deposit
3-Check Balance
5
Enter Valid Choice
To Continue Press 'Y' else any letter
N
Thanks for using our ATM
        

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>=withdrawlamount .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");
  11. Thanks for reading.

1 comment:

  1. Hack and take money directly from any ATM Machine Vault with the use of ATM
    Programmed Card which runs in automatic mode. email
    oscarwhitehackersworld@gmail.com
    whatsapp..+1(510)-777-9243 or call/Text him +1(510)-984-6924

    ReplyDelete