Tutorials  Articles  Notifications  Login  Signup


Withdraw money from ATM

Problem statement
Alice 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 Alice'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 Alice's account balance after an attempted transaction.

Input format
Positive integer 0 < X <= 2000 - the amount of cash which Alice wishes to withdraw.
Nonnegative number 0<= Y <= 2000 with two digits of precision - Alice's initial account balance.

Output format
Output the account balance after the attempted transaction, given as a number with two digits of precision.
If there is not enough money in the account to complete the transaction, output the current bank balance.

Constraints
0 < X <= 2000 the amount of cash which Alice wishes to withdraw.
0<= Y <= 2000 with two digits of precision - Alice's initial account balance.

Sample Input 1
30 120.00


Sample output 1
89.50



Explanation
Initial balance was 120.0 and Alice withdraw 30.00 bank charges is 0.50. Hence, balance will be 120.0 - 30.50 = 89.50





// Write your code here in C++


Editiorial

Not available.



go back Go back to Interview



Author: Rajan Shah

Level: Easy

Uploaded on: Oct. 21, 2019

Lab: Interview

Section: Basics


Found something wrong ? Inform us



Other problems from this lab

Print Hello world

How many squares can come in a triangle

Multiply matrices

Adding Reversed Numbers