cant understand why it is showing wrong answer

#include
#include
int main()
{
using namespace std;

int wdraw;
float bal;
float left;
cin >> wdraw;
cin >> bal;

if(wdraw <= bal)
{
    if(wdraw%5==0){
        left = bal-wdraw-0.50;
        cout << fixed << setprecision(2) << showpoint << left << endl;
        }
     else{

        cout << fixed << setprecision(2) << showpoint << bal << endl;

          }
}
else
{
        cout << fixed << setprecision(2) << showpoint << bal << endl;
}
return 0;

}

this is the ATM question in the easy section of the practice problems.
on submitting ,it shows Wrong Answer.
I have tried every possible input and it is giving me the correct answer on my compiler.

please help.

Check for this input

30 30.00

Output should be

  30.00

but ur output is -0.50 for this problem
Thats why it is being evaluated as WA.

The total balance initially should be greater than the withdrwal balance + the tax (0.50)

so condition should be Y > = x+0.50

@gauravagarwal :

your condition should be (wdraw+0.5)<=bal , otherwise the output of the program will be -0.5 in cases where withdraw is equal to balance.

link to your Accepted Solution : http://www.codechef.com/viewsolution/3222688

Wishes :slight_smile:

thanks .thank you so much @c0d3_k1ra and @squal

@gauravagrawal In case your doubt is solved, please upvote and/or accept their answer and appreciate their efforts

2 Likes

ur welcome :slight_smile:

//