This C# program simulates basic ATM transactions including checking balance, withdrawing cash, depositing cash, and exiting. The user is prompted to enter their PIN and then given a menu to select from the transaction options. Based on their selection, the program will either display the current balance, process a withdrawal or deposit by updating the running balance total, or thank the user for exiting. Validation is included to require withdrawal amounts be in multiples of 100 and ensure sufficient balance for withdrawals.
Download as TXT, PDF, TXT or read online on Scribd
0 ratings0% found this document useful (0 votes)
3K views
Atm C# Code
This C# program simulates basic ATM transactions including checking balance, withdrawing cash, depositing cash, and exiting. The user is prompted to enter their PIN and then given a menu to select from the transaction options. Based on their selection, the program will either display the current balance, process a withdrawal or deposit by updating the running balance total, or thank the user for exiting. Validation is included to require withdrawal amounts be in multiples of 100 and ensure sufficient balance for withdrawals.
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 3
/*
* C# Program to Display the ATM Transaction
*/ using System; class program { public static void Main() {
int amount = 1000, deposit, withdraw;
int choice, pin = 0, x = 0; Console.WriteLine("Enter Your Pin Number "); pin = int.Parse(Console.ReadLine()); while (true) { Console.WriteLine("********Welcome to ATM Service**************\ n"); Console.WriteLine("1. Check Balance\n"); Console.WriteLine("2. Withdraw Cash\n"); Console.WriteLine("3. Deposit Cash\n"); Console.WriteLine("4. Quit\n"); Console.WriteLine("********************************************* \n\n"); Console.WriteLine("Enter your choice: "); choice = int.Parse(Console.ReadLine()); switch (choice) { case 1: Console.WriteLine("\n YOUR BALANCE IN Rs : {0} ", amount); break; case 2:
Console.WriteLine("\n ENTER THE AMOUNT TO WITHDRAW: ");
withdraw = int.Parse(Console.ReadLine()); if (withdraw % 100 != 0) { Console.WriteLine("\n PLEASE ENTER THE AMOUNT IN MULTIPL ES OF 100"); } else if (withdraw > (amount - 500)) { Console.WriteLine("\n INSUFFICENT BALANCE"); } else { amount = amount - withdraw; Console.WriteLine("\n\n PLEASE COLLECT CASH"); Console.WriteLine("\n YOUR CURRENT BALANCE IS {0}", amou nt); } break; case 3: Console.WriteLine("\n ENTER THE AMOUNT TO DEPOSIT"); deposit = int.Parse(Console.ReadLine()); amount = amount + deposit; Console.WriteLine("YOUR BALANCE IS {0}", amount); break; case 4: Console.WriteLine("\n THANK U USING ATM"); break; } } Console.WriteLine("\n\n THANKS FOR USING OUT ATM SERVICE");