ATM Simulation System Using Java With Source Code

ATM Simulation System (CLI)

Introduction:

Thanks for visiting the ATM Stimulation System! This Command-Line User Interface (CLI)-based ATM Stimulation System offers a clear and easy way to execute withdrawals, deposits, and check balances. Java is the programming language used to create it. The system includes a simple command line interface with a switch case for executing deposits, withdrawals, and balance checks. It also updates the current balance after each operation. Anyone who needs to quickly calculate deposits and withdrawals should use this system. So, sit back, make a cup of coffee, and start calculating the amount in the ATM Stimulation System.

Explanation:

This Command-Line User Interface (CLI)-based ATM Stimulation System offers a clear and easy way to execute withdrawals, deposits, and check balances. The system includes a simple command line interface with a switch case for executing deposits, withdrawals, and balance checks. It also updates the current balance after each operation.

Source Code:

				
					import java.util.Scanner;

public class ATM {
    public static void main(String args[]) {
        // declare and initialize balance, withdraw, and deposit
        int balance = 5000, withdraw, deposit;
        // create scanner class object to get choice of user
        Scanner sc = new Scanner(System.in);
        while (true) {
            System.out.println("**Automated Teller Machine**");
            System.out.println("1. Withdraw");
            System.out.println("2. Deposit");
            System.out.println("3. Check Balance");
            System.out.println("4. EXIT");
            System.out.print("Choose the operation you want to perform:");

            // get choice from user
            int choice = sc.nextInt();
            switch (choice) {
                case 1:
                    System.out.print("Enter money to be withdrawn:");

                    // get the withdrawl money from user
                    withdraw = sc.nextInt();

                    // check whether the balance is greater than or equal to the withdrawal amount
                    if (balance >= withdraw) {
                        // remove the withdrawl amount from the total balance
                        balance = balance - withdraw;
                        System.out.println("Please collect your money");
                    } else {
                        // show custom error message
                        System.out.println("Insufficient Balance");
                    }
                    System.out.println("");
                    break;

                case 2:

                    System.out.print("Enter money to be deposited:");

                    // get deposite amount from te user
                    deposit = sc.nextInt();

                    // add the deposit amount to the total balanace
                    balance = balance + deposit;
                    System.out.println("Your Money has been successfully depsited");
                    System.out.println("");
                    break;

                case 3:
                    // displaying the total balance of the user
                    System.out.println("Balance : " + balance);
                    System.out.println("");
                    break;

                case 4:
                    // exit from the menu
                    System.exit(0);
                default:
                    //default statement
                    System.out.println("Invalid Choice");
            }
        }
    }
}
				
			

This system is built using Switch Case, while loop, and Scanner class. The system will first display the user’s available options. Withdraw, Deposit, Check Balance, and EXIT are available as choices. The user must choose a useful choice. The operation will be carried out as per the input choice, and the balance will be updated following each operation. The user could also get balance information in the “Check Balance” option.

Output:

ATM Stimulation System (CLI)

Find More Projects

Build a Quiz Game Using HTML CSS and JavaScript Introduction Hello coders, you might have played various games, but were you aware …

Emoji Catcher Game Using HTML CSS and JavaScript Introduction Hello Coders, Welcome to another new blog. In this article we’ve made a …

Typing Challenge Using HTML CSS and JavaScript Introduction Hello friends, all you developer friends are welcome to our new project. If you …

Breakout Game Using HTML CSS and JavaScript With Source Code Introduction Hello friends, welcome to today’s new blog post. All of you …

Digital and Analog Clock using HTML CSS and JavaScript Introduction : This project is a digital clock and stopwatch system, which allows …

Coffee Shop Website using HTML, CSS & JavaScript Introduction : This project is a website for coffee house business. It uses HTML …

All Coding Handwritten Notes