Whats wrong in this Logic?

Ques :- Contest Page | CodeChef

	public static void main (String[] args) throws java.lang.Exception
{
	// your code goes here
	
	int x;
	double y;
	
	Scanner sc = new Scanner (System.in);
	
	x = sc.nextInt();
	y = sc.nextDouble();
	

	if(x%5==0 && x<y)
	{
	    y=y-x-0.50;
	    
	}
	System.out.println(y);
	
}

there is only one problem:

y-x-0.5 should be 0 or more (you need to include the bank charge, $0.5 ) , if not print y

{
	// your code goes here
	
	int x;
	double y;
	
	Scanner sc = new Scanner (System.in);
	
	x = sc.nextInt();
	y = sc.nextDouble();

	if(x%5==0)
	{
		
		y = y-x-0.50;
		if(y < 0){
			y = y+x+0.5;
		}
		
	}
	System.out.println(y);
	
}