Advertisement
Guest User

Sn

a guest
Apr 25th, 2019
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.75 KB | None | 0 0
  1. #include<stdio.h>
  2. int main()
  3. {
  4.     int balance=0,tempPin;
  5.     int pin= 12345;
  6.     int anotherTransaction=1;
  7.  
  8.     printf("              Please enter your pin:");
  9.     scanf("%d",&tempPin);
  10.  
  11.     if(pin!=tempPin)
  12.     {
  13.       printf("\n             Invalid pin.");
  14.       return 0;
  15.     }
  16.     while(anotherTransaction==1)
  17.     {
  18.         int choice;
  19.  
  20.         printf("----------------------------------------------------\n");
  21.         printf("               Welcome To ATM Service\n");
  22.         printf("                1- Check balance\n");
  23.         printf("                2- Diposit cash\n");
  24.         printf("                3- Withdraw cash\n");
  25.         printf("----------------------------------------------------\n\n");
  26.         printf("enter your choice: ");
  27.         scanf("%d",&choice);
  28.  
  29.         if(choice==1){//check balance
  30.             printf("your balance is: $%d\n",balance);
  31.         }
  32.         else if(choice==2){
  33.             int amountDeposit;
  34.             printf("enter the amount to deposit: $");
  35.             scanf("%d",&amountDeposit);
  36.             balance=balance+amountDeposit;
  37.         }
  38.         else if(choice==3){
  39.             int amountWithdraw;
  40.             printf("Enter the amount to withdraw: $");
  41.             scanf("%d",&amountWithdraw);
  42.             balance=balance-amountWithdraw;
  43.         }
  44.         else{
  45.             printf("Invalid transaction.\n");
  46.         }
  47.  
  48.     anotherTransaction=0;
  49.  
  50.     while(anotherTransaction!=1 && anotherTransaction!=2)
  51.     {
  52.         printf("do you want to do another transaction:\n");
  53.         printf("1- Yes, 2- No\n");
  54.         scanf("%d",&anotherTransaction);
  55.     }
  56.     if (anotherTransaction==2){
  57.        printf("_______________thanks for using_______________");
  58.     }
  59.     }
  60.     return 0;
  61.  
  62. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement