-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathATM.java
More file actions
32 lines (27 loc) · 857 Bytes
/
ATM.java
File metadata and controls
32 lines (27 loc) · 857 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import java.util.Scanner;
class ATM {
private int pin = 1234;
private double balance = 5000;
public boolean authenticate(int enteredPin) {
return pin == enteredPin;
}
public void checkBalance() {
System.out.println("Current Balance: ₹" + balance);
}
public void deposit(double amount) {
if (amount > 0) {
balance += amount;
System.out.println("Deposit successful.");
} else {
System.out.println("Invalid amount.");
}
}
public void withdraw(double amount) {
if (amount > 0 && amount <= balance) {
balance -= amount;
System.out.println("Please collect your cash.");
} else {
System.out.println("Insufficient balance or invalid amount.");
}
}
}