ATM Problem(easy)

Hey,can anyone figure out why i am getting it wrong according to codechef judge?


#include 

int main(void) {
	
	int X;
	float Y;
	
	scanf("%d%f",&X,&Y);
	
	if(X%5 !=0 || X>Y){
	    
	    printf("%.2f",Y);
	    
	}
	
	else{
	    
	    printf("%.2f",Y-0.50-X);
	    
	}
	
	return 0;
}


Thanks

See your logic is correct but you forgot one case i guess
suppose your account is having 120 and you want to withdraw 120$ then the answer will be -0.50 which is not possible, that is your account is not having sufficient money for the transaction , so you need it add a case for that
:slight_smile:

120 120.20
120.20

for this testcase,your code will print negative. Just a corner case.

1 Like

hey, but i don’t think that X can be a decimal value.

Okay-check this testcase.

yeah but what about second case which you had given ie 120.20 its just have one input

i accepted but why it is not possible?

it is mentioned in the problem statement that your account should have sufficient balance so that transaction should take place. so to do a transaction of 120 your account should hold a minimum amount of 120.50

That is the output of the testcase,not input.