- Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathATM.java
More file actions
Latest commit
29 lines (25 loc) · 592 Bytes
/
Copy pathATM.java
File metadata and controls
29 lines (25 loc) · 592 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
importjava.util.*;
classATM {
publicstaticvoidmain(String[] args) {
Scanners = newScanner(System.in);
try {
doublewithdrawal = s.nextDouble();
doublebalance = s.nextDouble();
s.close();
balance = performWithdrawal(withdrawal, balance);
System.out.println(balance);
} catch(Exceptione) {}
System.exit(0);
}
publicstaticdoubleperformWithdrawal(doublewithdrawal, doublebalance) {
if (withdrawal % 5 == 0 &&
withdrawal > 0)
{
withdrawal += .5;
if (balance >= withdrawal) {
balance -= withdrawal;
}
}
returnbalance;
}
}