-
Notifications
You must be signed in to change notification settings - Fork 0
/
ATM
31 lines (24 loc) · 1.02 KB
/
ATM
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
ATM
Problem
Pooja would like to withdraw X $US from an ATM.
The cash machine will only accept the transaction if X is a multiple of 5, and Pooja's account balance has enough cash to perform the withdrawal transaction (including bank charges).
For each successful withdrawal the bank charges 0.50 $US.
Calculate Pooja's account balance after an attempted transaction.
// We have populated the solutions for the 10 easiest problems for your support.
// Click on the SUBMIT button to make a submission to this problem.
import java.util.*;
import java.io.*;
class Solution{
public static void main(String[] args) throws Exception{
InputStreamReader i = new InputStreamReader(System.in);
BufferedReader bf = new BufferedReader(i);
String[] in = bf.readLine().split(" ");
float n = Float.parseFloat(in[0]);
float f = Float.parseFloat(in[1]);
if(n%5==0 && f>=n+0.5f)
System.out.println(f-n-0.5f);
else{
System.out.println(f);
}
}
}