Sunday, 9 April 2017

C# Program to Display the ATM Transaction

  1. /*
  2.  * C# Program to Display the ATM Transaction
  3.  */
  4. using System;
  5. class program
  6. {
  7.     public static void Main()
  8.     {
  9.  
  10.         int amount = 1000, deposit, withdraw;
  11.         int choice, pin = 0, x = 0;
  12.         Console.WriteLine("Enter Your Pin Number ");
  13.         pin = int.Parse(Console.ReadLine());
  14.         while (true)
  15.         {
  16.             Console.WriteLine("********Welcome to ATM Service**************\n");
  17.             Console.WriteLine("1. Check Balance\n");
  18.             Console.WriteLine("2. Withdraw Cash\n");
  19.             Console.WriteLine("3. Deposit Cash\n");
  20.             Console.WriteLine("4. Quit\n");
  21.             Console.WriteLine("*********************************************\n\n");
  22.             Console.WriteLine("Enter your choice: ");
  23.             choice = int.Parse(Console.ReadLine());
  24.             switch (choice)
  25.             {
  26.             case 1:
  27.                 Console.WriteLine("\n YOUR BALANCE IN Rs : {0} ", amount);
  28.                 break;
  29.             case 2:
  30.                 Console.WriteLine("\n ENTER THE AMOUNT TO WITHDRAW: ");
  31.                 withdraw = int.Parse(Console.ReadLine());
  32.                 if (withdraw % 100 != 0)
  33.                 {
  34.                     Console.WriteLine("\n PLEASE ENTER THE AMOUNT IN MULTIPLES OF 100");
  35.                 }
  36.                 else if (withdraw > (amount - 500))
  37.                 {
  38.                     Console.WriteLine("\n INSUFFICENT BALANCE");
  39.                 }
  40.                 else
  41.                 {
  42.                     amount = amount - withdraw;
  43.                     Console.WriteLine("\n\n PLEASE COLLECT CASH");
  44.                     Console.WriteLine("\n YOUR CURRENT BALANCE IS {0}", amount);
  45.                 }
  46.                 break;
  47.             case 3:
  48.                 Console.WriteLine("\n ENTER THE AMOUNT TO DEPOSIT");
  49.                 deposit = int.Parse(Console.ReadLine());
  50.                 amount = amount + deposit;
  51.                 Console.WriteLine("YOUR BALANCE IS {0}", amount);
  52.                 break;
  53.             case 4:
  54.                 Console.WriteLine("\n THANK U USING ATM");
  55.             break;
  56.             }
  57.         }
  58.         Console.WriteLine("\n\n THANKS FOR USING OUT ATM SERVICE");
  59.     }
  60.  }

No comments:

Post a Comment