Write a java program for atm machine

Write a java program for atm machine. This is a Java program that shows how to display an ATM transaction. As input, the user will select one of the offered alternatives. For different procedures such as withdraw, deposit, and check balance, multiple switch cases have been supplied.

import java.util.Scanner;
public class Main
{
public static void main(String args[] )
{
int balance = 1000, withdraw, deposit;
Scanner s = new Scanner(System.in);
while(true)
{
System.out.println("Welcome to State bank of india");
System.out.println("Choose 1 for Withdraw");
System.out.println("Choose 2 for Deposit");
System.out.println("Choose 3 for Check Balance");
System.out.println("Choose 4 for Exit");
System.out.print("Choose the operation you want to perform");
int n = s.nextInt();
switch(n)
{
case 1:
System.out.print("Enter money to be withdraw");
withdraw = s.nextInt();
if(balance >= withdraw)
{
balance = balance - withdraw;
System.out.println("Please collect your money");
}
else
{
System.out.println("Insufficient Balance");
}
System.out.println("");
break;

case 2:
System.out.print("Enter money to be deposited:");
deposit = s.nextInt();
balance = balance + deposit;
System.out.println("Your Money has been successfully deposited");
System.out.println("");
break;

case 3:
System.out.println("Balance : "+balance);
System.out.println("");
break;

case 4:
System.exit(0);
}
}
}
}

 

Output:

Welcome to State bank of india
Choose 1 for Withdraw
Choose 2 for Deposit
Choose 3 for Check Balance
Choose 4 for Exit
Choose the operation you want to perform1
Enter money to be withdraw 455
Please collect your money

What is ATM and how it works

An automated teller machine (ATM) is an electronic banking terminal that enables consumers to conduct simple transactions without the assistance of a teller or branch personnel. At most ATMs, anyone with a credit or debit card can get cash.

Automated Teller Machines, or ATMs, are one of the most beneficial innovations in the banking industry. Customers can use ATMs to perform self-service operations such cash withdrawals, deposits, and fund transfers.

To conduct a transaction at an ATM, customers must use a plastic card—either a bank debit card or a credit card. Before any transaction can be completed, consumers must be validated using a PIN. A chip is found on many cards, and it transmits data from the card to the machine.

What is switch case and how it works

A switch statement allows a variable to be compared against a list of values for equality. Each value is referred to as a case, and each case is verified against the variable that is being turned on.