Search
 
SCRIPT & CODE EXAMPLE
 

JAVA

atm machine java project

import java.util.Scanner;
public class ATM_Transaction
{
    public static void main(String args[] )
    { 
        int balance = 5000, withdraw, deposit;
        Scanner s = new Scanner(System.in);
        while(true)
        {
            System.out.println("Automated Teller Machine");
            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 withdrawn:");
                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 depsited");
                System.out.println("");
                break;
 
                case 3:
                System.out.println("Balance : "+balance);
                System.out.println("");
                break;
 
                case 4:
                System.exit(0);
            }
        }
    }
}
Comment

PREVIOUS NEXT
Code Example
Java :: java arraylist with double 
Java :: How to get a context in a recycler view adapter 
Java :: valueof in java 
Java :: android studio remove button onclick 
Java :: how to create xml file in java 
Java :: settext java 
Java :: set matrix zeros 
Java :: static class java 
Java :: how to read text file as variable in java 
Java :: can i have both java7 and java 11 in mac 
Java :: java bigdecimal 
Java :: junit check class type 
Java :: objectmapper in java 8 
Java :: get all enum values java 
Java :: arrays.sum 
Java :: android generate random int 
Java :: spring properties list 
Java :: return two values in java 
Java :: java try-with-resources 
Java :: initializing list in java 
Java :: call fragment method from activity 
Java :: java grösser gleich 
Java :: get free player inventory slots spigot 
Java :: android java change text value 
Java :: implements java 
Java :: change attributes of player spigot 
Java :: how to merge two arrays in java 
Java :: split on . in java 
Java :: what is a cache-less reload 
Java :: binary search algorithm in java 
ADD CONTENT
Topic
Content
Source link
Name
6+7 =