ATM question wrong answer :(

I tried to do this for the ATM question and cracking my head for really long time but I really couldnt figure out what is the problem with my code. This is my first time submitting my own code. Hope to get to learn more from you guys!

import java.util.Scanner;

class ATM {
public static void main(String args[]){
Scanner input = new Scanner(System.in);

	float withdraw;
	float balance;
	
	withdraw = input.nextFloat();
	balance = input.nextFloat();
	
	balance = (float) (balance - withdraw - 0.50);
	
	if(withdraw % 5 == 0 && withdraw <= balance && withdraw >=0 && withdraw <= 2000){
		System.out.println(balance);
	}
	else
	{
		balance = (float) (balance + 0.50 + withdraw);
		System.out.println(balance);
	}
}

}

Here is the correct pseudo code for the problem. Now read the question carefully, then read this pseudo code below, then take a look at conditions inside if in your code.

 int withdraw=input()
 float balance=input()
 ans=balance
 if (withdraw % 5 == 0 && withdraw+0.5< balance)
    {
     ans = balance - (withdraw + 0.50);
    }
print ans

You need to ensure that ans has only 2 digits after the decimal point.


If you have any problem you can comment below.

//