Javamicroproject 2
Javamicroproject 2
Abstract
1. Introduction
2. Problem Statement
3. Objectives
4. System Requirements
5. Software and Tools Used
6. System Design
6.1 UML Diagrams
6.2 Class Diagram
7. Implementation
7.1 program of ATM machine
7.2 Code Explanation
8. Output of ATM machine code
9. Results and Observations
10. Future Enhancements
11. Conclusion
12. References
1. Introduction :
Hardware Requirements :-
I. Processor: Intel i3 or above
II. RAM: 4GB minimum
III. Storage: 500MB
IV. Software Requirements
V. Java Development Kit (JDK)
VI. Integrated Development
Environment (IDE) (Eclipse, IntelliJ, or
NetBeans)
---
5. Software and Tools Used :
class Account {
private String accountNumber;
private String accountHolderName;
private double balance;
private String pin; // Added PIN for security
// Get balance
public double getBalance() {
return balance;
}
// Verify PIN
public boolean verifyPin(String enteredPin) {
return this.pin.equals(enteredPin);
}
// Deposit method
public void deposit(double amount) {
if (amount > 0) {
balance += amount;
System.out.println("Successfully deposited $"
+ amount);
} else {
System.out.println("Invalid deposit
amount!");
}
}
// Withdrawal method
public void withdraw(double amount) {
if (amount > 0 && amount <= balance) {
balance -= amount;
System.out.println("Successfully withdrawn
$" + amount);
} else {
System.out.println("Insufficient balance or
invalid amount!");
}
}
// Display balance
public void checkBalance() {
System.out.println("\n Account Details =====");
System.out.println("Account Holder: " +
accountHolderName);
System.out.println("Account Number: " +
accountNumber);
System.out.println("Account Balance: $" +
balance);
}
}
scanner.nextLine();
while (true) {
System.out.println("\nMini ATM ");
System.out.println("1. Deposit");
System.out.println("2. Withdraw");
System.out.println("3. Check Balance");
System.out.println("4. Exit");
System.out.print("Choose an option: ");
if (choice == 4) {
System.out.println("Thank you for using
my ATM");
scanner.close();
return;
}
if (account.verifyPin(enteredPin)) {
authenticated = true;
break;
} else {
System.out.println("Incorrect PIN!
Attempts left: " + (3 - attempts));
}
}
if (!authenticated) {
System.out.println("Too many incorrect
pin! Exiting...");
break;
}
switch (choice) {
case 1:
System.out.print("Enter deposit amount:
");
double depositAmount =
scanner.nextDouble();
account.deposit(depositAmount);
break;
case 2:
System.out.print("Enter withdrawal
amount: ");
double withdrawAmount =
scanner.nextDouble();
account.withdraw(withdrawAmount);
break;
case 3:
account.checkBalance();
break;
default:
System.out.println("Invalid option!
Please try again.");
}
}
}
}
Code Breakdown
Methods:
getAccountNumber(),
getAccountHolderName(), getBalance() →
Retrieve details.
PIN Authentication:
Key Features
Mini ATM
1. Deposit
2. Withdraw
3. Check Balance
4. Exit
Choose an option: 1
Enter your 4-digit PIN: 9730
Enter deposit amount: 20000
Successfully deposited $20000.0
Mini ATM
1. Deposit
2. Withdraw
3. Check Balance
4. Exit
Choose an option: 3
Enter your 4-digit PIN: 9730
Mini ATM
1. Deposit
2. Withdraw
3. Check Balance
4. Exit
Choose an option: 2
Enter your 4-digit PIN: 9730
Enter withdrawal amount: 20000
Successfully withdrawn $20000
Mini ATM
1. Deposit
2. Withdraw
3. Check Balance
4. Exit
Choose an option: 3
Enter your 4-digit PIN: 2563
Incorrect PIN! Attempts left: 2
Enter your 4-digit PIN: 426
Incorrect PIN! Attempts left: 1
Enter your 4-digit PIN: 537
Incorrect PIN! Attempts left: 0
Too many incorrect pin! Exiting...
[Program finished]
11. Conclusion :
This project successfully simulates an ATM
machine with basic banking functionalities.
The use of OOP ,JAVA principles ensures
modular, scalable, and maintainable code.
12. References :
Java Documentation:
https://docs.oracle.com/javase/