competitive coding



Problem Statement

Ram would like to withdraw X INR 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 ₹INR. Calculate Ram'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.


CASE 1:- Successful transaction
Input:
50 170.00

Output:
119.50

CASE 2:- Incorrect Withdrawal amount(not multiple of 5)
Input:
423 1120.00
Output:
1120.00
CASE 3:- Insufficient Funds
Input:
800 120.00
Output:
120.00




CODE:-

#include<iostream>
#include<iomanip>
using namespace std;
int main ()
{
int x;
float a;
cin>>x>>a;
if(x%5==0 && ((a-x-0.5)>0)
{
cout<<fixed<<setprecision(2)<<(a-x-0.5);
}
else {
cout<<fixed<<setprecision(2)<<(a);
}
return 0;
}
Thanks For reading. comment below for any query.
If you need this code in any other language please do ask us for that.