Java Project ATM Machine
java project atm machineUse the Account class created to simulate an ATM machine. Create 10 accounts with id AC001…..AC010 with initial balance 300₹. The system prompts the users to enter an id. If the id is entered incorrectly, ask the user to enter a correct id. Once an id is accepted, display me
This java project atm machine is for ISC computer students.
Watch java videos
java project atm machine
Use the Account class created to simulate an ATM machine. Create 10 accounts with id AC001…..AC010 with initial balance 300₹. The system prompts the users to enter an id. If the id is entered incorrectly, ask the user to enter a correct id. Once an id is accepted, display menu with multiple choices.
java project atm machine
1. Balance inquiry
2. Withdraw money [Maintain minimum balance 300₹]
3. Deposit money
4. Money Transfer
5. Create Account
6. Deactivate Account
In this program array list and iterator class have been used.
The Arraylist class is a re sizable array, which can be found in the java.util package.
'Iterator’ is an interface which belongs to collection framework. It allows us to traverse the collection, access the data element and remove the data elements of the collection.(In this program collection is the array list)
java.util package has public interface Iterator and contains three methods:
- boolean hasNext(): It returns true if Iterator has more element to iterate.
- Object next(): It returns the next element in the collection until the hasNext()method return true.
- void remove(): It removes the current element in the collection.
import java.lang.*;
import java.util.*;
class Account
{
String id;
int balance;
Account(String i)
{
id = i;
balance = 300;
}
void BalanceInq()
{
System.out.println("ID :- " + id);
System.out.println("Balance :- " + balance);
}
void withdraw()
{
int temp;
Scanner sc = new Scanner(System.in);
System.out.print("Enter amount to withdraw :- ");
temp = sc.nextInt();
if(balance - temp < 300)
System.out.println("Minimum 300 balance is needed");
else
{
balance = balance - temp;
System.out.println("Current balance :- " + balance);
}
}
void deposit()
{
int temp;
Scanner sc = new Scanner(System.in);
System.out.print("Enter amount to deposite :- ");
temp = sc.nextInt();
balance = balance + temp;
System.out.println("Current balance :- " + balance);
}
void moneyTransfer(ArrayList ar)
{
int temp;
String id;
Scanner sc = new Scanner(System.in);
Account ac = null;
System.out.print("Enter ID to transfer :- ");
id = sc.next();
Iterator itr = ar.iterator();
while(itr.hasNext())
{
Account a = (Account) itr.next();
if(id.equals(a.id))
ac = a;
}
if(ac == null)
System.out.println("Account not found");
else
{
System.out.print("Enter amount to transfer :- ");
temp = sc.nextInt();
if(temp > balance)
System.out.println("Not enough balane to transfer");
else
{
ac.balance = ac.balance + temp;
balance = balance - temp;
}
}
}
void Create(ArrayList arr)
{
String str;
Scanner sc = new Scanner(System.in);
System.out.print("Enter ID :- ");
str = sc.next();
Account ac = new Account(str);
arr.add(ac);
}
void delete(ArrayList arr)
{
String str;
Scanner sc = new Scanner(System.in);
Account ac = null;
System.out.print("Enter ID :- ");
str = sc.next();
Iterator itr = arr.iterator();
while(itr.hasNext())
{
Account a = (Account) itr.next();
if(str.equals(a.id))
ac = a;
}
if(ac == null)
System.out.println("Account not found");
else
{
arr.remove(ac);
System.out.println("Account removed successfully");
}
}
}
public class java13
{
public static void main(String[] args)
{
ArrayList<Account>arr = new ArrayList<Account>();
Scanner sc = new Scanner(System.in);
String str;
int op;
Account ac = null;
Account a = new Account(null);
arr.add(new Account("AC001"));
arr.add(new Account("AC002"));
arr.add(new Account("AC003"));
arr.add(new Account("AC004"));
arr.add(new Account("AC005"));
arr.add(new Account("AC006"));
arr.add(new Account("AC007"));
arr.add(new Account("AC008"));
arr.add(new Account("AC009"));
arr.add(new Account("AC010"));
System.out.print("Enter your ID :- ");
str = sc.next();
Iterator itr = arr.iterator();
while(itr.hasNext())
{
a = (Account) itr.next();
if(str.equals(a.id))
ac = a;
}
if(ac == null)
{
System.out.println("Invalid ID");
System.exit(0);
}
else
{
do
{
System.out.println("Press 1 - for Balance Inquiry");
System.out.println("Press 2 - for Withdraw");
System.out.println("Press 3 - for Deposit");
System.out.println("Press 4 - for Money Transfer");
System.out.println("Press 5 - for Create Account");
System.out.println("Press 6 - for Remove Account");
System.out.println("Press 0 - for Exit");
System.out.print("Enter your choice => ");
op = sc.nextInt();
switch(op)
{
case 1:
ac.BalanceInq();
break;
case 2:
ac.withdraw();
break;
case 3:
ac.deposit();
break;
case 4:
ac.moneyTransfer(arr);
break;
case 5:
ac.Create(arr);
break;
case 6:
ac.delete(arr);
break;
case 0:
System.out.println("Thank you");
break;
default:
System.out.println("Invalid input");
}
}while(op != 0);
}
}
Download free Sample papers
Related Posts
Continue learning with these related articles

ISC Practical 2027: College Enrolment Code Validator and Stream Report – Algorithm and Java Program
Fully solved ISC Computer Science Practical 2027 question: validate college enrolment codes made of a stream, year and serial number, give the exact reason for each rejection, auto-correct lowercase streams and prepare a stream-wise report.

ISC Practical 2027: Digital Lock Security Code Analyzer – Algorithm and Java Program
Fully solved ISC Computer Science Practical 2027 number-logic question: for a 5 to 10 digit security code, find the first and last digits, odd and even position sums, product of non-zero digits, digit frequency and classify the code as STRONG, MODERATE or WEAK.

Boolean Algebra for ISC Class 12: Laws, Canonical SOP and POS, and Simplification
ISC Class 12 Computer Science notes on Boolean algebra: all the laws and theorems, duality, De Morgan's laws, minterms and maxterms, converting to canonical SOP and POS, and step-by-step algebraic simplification with solved examples.