-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathATM
More file actions
27 lines (23 loc) · 983 Bytes
/
ATM
File metadata and controls
27 lines (23 loc) · 983 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
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.text.DecimalFormat;
public class ATM {
public static void main(String[] args) throws IOException {
String currentLine;
String[] lineArray;
BufferedReader sc = new BufferedReader(new InputStreamReader(System.in));
while((currentLine = sc.readLine()) != null){
lineArray = currentLine.split(" ");
double fee = 0.5;
Double accountWithdraw = Double.parseDouble(lineArray[0]);
Double accountBalance = Double.parseDouble(lineArray[1]);
Double afterBalance = balance-withdraw-fee;
if(afterBalance < 0 || accountWithdraw%5 != 0){
afterBalance = accountBalance;
}
DecimalFormat money = new DecimalFormat("#.00");
System.out.println(money.format(afterBalance));
}
}
}