runtime error for Java (Problem: ATM , beginner section)

import java.util.*;
public class Main {

    public static void main (String[] args) {
        
        Scanner sc = new Scanner (System.in);
        
        int X = sc.nextInt();
        double Y = sc.nextInt();
        
        if(X % 5 == 0 && X < Y) {
            
            double q = Y - X - .50;
            System.out.printf("%.2f\n",q);
            
        }
        
        else if((X % 5 == 0)  && (X > Y)) {
            
            System.out.printf("%.2f\n",Y);
            
        }
        
        else {
            
            System.out.printf("%.2f\n",Y);
            
        }
        
    }
    
}

I think this line is incorrect-

double Y = sc.nextInt();

Also, this condition can give WA-

`if(X % 5 == 0 && X < Y) {

        double q = Y - X - .50;`

Lets say accound has 120.10 ruppess and you withdraw 120. With bank charges, your account should have 120.50 for successful withdrawl, which it has not.

1 Like