Code chef : ATM problem
// CODE: HS08TEST
// logic
// the withdrawal amount should be a multiple of 5
// the bank balance should not be equal to the
// withdrawal amount because for every transaction
// the bank charges 0.50 USD.
// the withdrawal amount should be an int whereas
// the bank balance and remaining balance after
// transaction should be float with 2 digits
// precision.
#include <iostream>
int main()
{
int x;
float y;
float z{0.5};
std::cin >> x ;
std::cin >> y ;
if (x%5 == 0 && x<y && (x + 0.5) <= y)
{
std::cout << double(y - x - z);
}
else
{
std::cout << double(y);
}
return 0;
}
Comments
Post a Comment