Require help in submission of code, Problem Code:HS08TEST

#include
#include
using namespace std;

int main() {
int withdraw;
double balance;
double left;

cin>>withdraw;
cin>>fixed>>setprecision(2)>>balance;

if((balance>=0)&&(balance<=2000))
{
    if((withdraw>0)&&(withdraw<=2000))
    {
     if((withdraw%5==0)&&(balance-withdraw)>0)
        {
            left=balance-withdraw;
            left-=0.50;
            cout<<fixed<<setprecision(2)<<left;
            cout<<endl;
    
        }
        else
        {
            cout<<fixed<<setprecision(2)<<balance;
            cout<<endl;
    
        }
    }
    
}
// your code goes here
return 0;

}

It is my solution in python:

x,y = map(float,input().split())
if x % 5 == 0:
      if x + 0.5 <= y:
            y -= (x + 0.5)
            
print(y)

Very simple logic. Now, try it in C++.

I will, but I want to know my code is not accepted although it is showing correct output.

@disha_999 No,it’s not.
for this input:

0 120

Your code print nothing.
But it should print 119.5
Read the question well, you can understand it.
For my accepted solution it prints 119.5 for the input 0 120. If you have doubt you can see the output for another accepted solution in all submission. it prints 119.5 for the input 0 120. So, your code got WA.
There are multiple wrong in your code. So, you should try a simpler code for this problem.

Thanks a lot, for helping again:)

You are Welcome. :slightly_smiling_face:

Is there any way to check our code on more number of test cases to check whether it works properly or not or we have to check it by randomly putting values every time.

@disha_999 you can check your code on more number of testcases. Just you have to do this:
first line of your code should be(in python):

t = int(input())
for i in range(t) : 
    "Then paste your whole code here"

I generally do this. I make valid input file first. like input.txt. My file generally contain 100+ valid input. After executing my code I give the number of testcase as t. And then I paste all valid input here and get a number of output for input. :slightly_smiling_face:

P S: You can do it in C++ following this method.

@disha_999 but 0<X<=2000 so how come X=0

Yes, the constraints here is confusing! But in output there is a line like:

 If there is not enough money in the account to complete the transaction, output the current bank balance.

And for each withdraw your charge is 0.5
And your account main(current) balance is 120
And after withdraw, your output should be 119.5

Okhay🙂