C# program to display ATM Transaction

Algorithm:-

(1)First take pin number from user and compare if pin is  valid then give 4 option balance inquery,cash withdraw,cash deposits and exit if pin is invalid  print the message invalid pin number

(2)store selected option in integer variable

(3)if we  choose first option the balance inquiry operation will perform,if we choose second option cash withdraw operation will perform, if we choose 3rd operation cash deposits operation will perform , if we choose 4th opetion then all operation will exit and thank you message will show.

(4)after that give thank you message.


using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

using System.Threading.Tasks;


namespace TestApplicationOnly

{

    class Program

    {

        static void Main(string[] args)

        {

          try

          {

              int totalBalance = 50000, deposit = 0, withdraw = 0;

              int atmpin = 0,option;

              Console.Write("Enter Your ATM Pin: ");

              atmpin = Convert.ToInt32(Console.ReadLine());

              if (atmpin == 6543)

              {

                  Console.WriteLine("*****************Welcome to SBI ATM Service*****************\n");

                  Console.WriteLine("1. Balance Enquiry\n");

                  Console.WriteLine("2. Cash Withdrawal\n");

                  Console.WriteLine("3. Cash Deposit\n");

                  Console.WriteLine("4. Exit\n");

                  Console.WriteLine("************************************\n\n");

                  Console.Write("Select option: ");


             option = Convert.ToInt32(Console.ReadLine());


                  switch (option)

                  {

                      case 1:

                          Console.Write("\nYour Total Account Balanace : " + totalBalance);

                          break;

                      case 2:

                          Console.Write("\nEnter withdrawal amount: ");

                          withdraw = Convert.ToInt32(Console.ReadLine());


                          if (withdraw % 100 != 0)

                          {

                              Console.WriteLine("\nPlease enter withdrawal amount in multiple of 100 and above 100");

                          }

                          else if (withdraw > totalBalance)

                          {

                              Console.WriteLine("\nInSufficient balance in your account");

                          }

                          else

                          {

                              totalBalance = totalBalance - withdraw;

                              Console.WriteLine("\n\nPlease collect your money");

                              Console.WriteLine("\nYour Current balance is: " + totalBalance);

                          }

                          break;

                      case 3:

                          Console.Write("\nEnter amount to deposit: ");

                          deposit = Convert.ToInt32(Console.ReadLine());

                          totalBalance = totalBalance + deposit;

                          Console.WriteLine("Your current balance is : " + totalBalance);

                          break;

                      case 4:

                          Console.WriteLine("\nThank you for using ATM Services");

                          break;

                         

                  }

              }

              else

              {

                  Console.WriteLine("Invalid Pin Number");

                 

              }

              Console.WriteLine("\n\nTHANKS FOR USING OUT ATM SERVICE");

                         

           }

            catch (Exception ex)

            {

                Console.WriteLine("Input is not in correct formate");

            }

            Console.ReadKey();               

        }

    }

}


Output:-

Enter Your ATM Pin: 6543

*****************Welcome to SBI ATM Service*****************

1. Balance Enquiry

2. Cash Withdrawal

3. Cash Deposit

4. Exit

************************************


Select option: 1

Your Total Account Balanace : 50000

THANKS FOR USING OUT ATM SERVICE


Select option: 2

Enter withdrawal amount: 10000

Please collect your money

Your Current balance is: 40000


Select option: 3

Enter amount to deposit: 20000

Your current balance is : 70000

THANKS FOR USING OUT ATM SERVICE


Select option: 4

Thank you for using ATM Services

THANKS FOR USING OUT ATM SERVICE

एक टिप्पणी भेजें

0 टिप्पणियाँ