ATM keeps getting error.

It shows correct output but I don’t know why it keeps getting wrong answer :frowning:

import java.util.Scanner;

public class Main{

	public static void main(String[] args){

		int num1;
		double num2;
		Scanner scan = new Scanner(System.in);
		num1 = scan.nextInt();
		num2 = scan.nextDouble();
		
		if(num1 % 5 == 0 && num2 >= num1)
		{
			num2 = num2-num1-0.50;
			System.out.printf("%.2f\n",num2);
		}
		else 
		{
			System.out.printf("%.2f\n",num2);
		}
	}
}

Hi, you are not considering the transaction charge in your if condition.
For example, its is not possible to withdraw $5 when the balance is exactly $5 whereas your code would print -0.50 .

consider the transaction charge. like if(a<500) System.println(“Insufficient Amount”); etc like this

you have missed 1 condition … what happens if she want to withdraw 2000 and in her account only 2000 is available… add 1 more condition that (withdraw+0.50)<=available balance…

instead of num2>=num1 write this (num2-num1)>=0.50 as there should be minimum $0.50 in the account ,only then transaction is possible!####