ATM
Practice this coding question on Coding Gurukul.
Problem statement
A student uses a training ATM simulator that dispenses withdrawals only in multiples of 5 currency units. Every successful withdrawal also incurs a fixed fee of 0.50 units. The simulator must either complete the entire withdrawal and fee together or leave the account untouched. You are implementing the balance calculation shown after a single request. Your task Read the requested integer withdrawal x and the current balance y. Approve the request only when x is divisible by 5 and y is at least x + 0.50. On approval, subtract both the withdrawal and the fee. Otherwise keep the original balance. Print the resulting balance with exactly two decimal places. Important details Having enough money for x alone is insufficient if the fee cannot also be paid. No fee is charged for a rejected request. Use cents or careful decimal handling to avoid rounding errors at the boundary. Worked example For a withdrawal of 20 from a balance of 50.00, the total debit is 20.50 and the remaining balance is 29.50.
Input format
One line: integer x followed by balance y with up to two decimal places.
Output format
Print the remaining balance with exactly two decimal places.
Constraints
1 <= x <= 2000; 0 <= y <= 2000.00.
Sample input
20 50.00
Sample output
29.50
Sign in to run or submit a solution in C++, Java or Python.