runtime error(NZEC) coming up everytime

import java.util.*;
public class Main {

public static void main(String[] args) {

    int withdrawalMoney;
    double currBalance, remBalance;
    Scanner input = new Scanner(System.in);
    //System.out.println("CurrentBalance is: ");
    currBalance = input.nextDouble();
    //System.out.println("Enter the amount to be withdrawal: ");
    withdrawalMoney = input.nextInt();
    if(withdrawalMoney%5==0 && currBalance>withdrawalMoney+0.50){
        remBalance = currBalance - withdrawalMoney - 0.50;
        System.out.printf("%.2f",remBalance);
    }
    else{
        System.out.printf("%.2f",currBalance);
    }

}

}

Your code seems fine i ran it on my system for several test case to just make sure it works fine !! just make sure withdrawalMoney is a integer input so if u try input for float or double it will raise an exception!

1 Like

ATM TEST

withdrawalMoney = input.nextInt(); ->withdrawalMoney = input.nextDouble();

it is showing the wrong answer now. Don’t know what to do. Working absolutely fine one my system but on codechef it is showing wrong.