### ATM Problem : HS08TEST

### ATM Problem Codechef Solution in C, C++, JAVA and Python

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.

### Input

Positive integer 0 < X <= 2000 – the amount of cash which Pooja wishes to withdraw.

Nonnegative number 0<= Y <= 2000 with two digits of precision – Pooja’s initial account balance.

### Output

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.

### Example – Successful Transaction

```Input:
30 120.00

Output:
89.50
```

### Example – Incorrect Withdrawal Amount (not multiple of 5)

```Input:
42 120.00

Output:
120.00
```

### Example – Insufficient Funds

```Input:
300 120.00

Output:
120.00```

## ATM Problem Codechef Solution in C

``````//www.progies.in
int main(){
int a;
float b;
scanf("%d",&a);
scanf("%f",&b);
if(a%5==0){
float c;
c=b-(float)a-0.5;
if(c < 0) printf("%.2f",b);
else
printf("%.2f",c);
}
else{
printf("%.2f",b);
}
}``````

## ATM Problem Codechef Solution in C++ 14

``````
int main() {
int w;
float ac_bl;
cin>>w;
cin>>ac_bl;
if(w%5==0 && w < =ac_bl-0.5){
cout << ((ac_bl-w)-(0.5));
}
else{
cout << ac_bl;
}
return 0;
}``````

## ATM Problem Codechef Solution in Python 3

``````# 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.

#Note that it's python3 Code. Here, we are using input() instead of raw_input().
#You can check on your local machine the version of python by typing "python --version" in the terminal.

n,atm=map(float,input().split())
n=int(n)
if (n+0.5 <=atm and n%5==0):
print(float(atm-n-0.5))
else:
print(float(atm))

``````

## ATM Problem Codechef Solution in Java

``````
import java.util.*;
import java.io.*;

class Solution{
public static void main(String[] args) throws Exception{
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);
}

}
}
``````

This was ATM Problem Codechef Solution

* The material and content uploaded on this website are for general information and reference purposes only. Please do it by your own first.

### The Cheaper Cab: CABS

ATM Problem Codechef Solution