import java.util.Scanner; class ATM { public static void main(String args[]) { Scanner obj = new Scanner(System.in); System.out.println("Enter amount to be withdrawn"); int wit = obj.nextInt(); System.out.println("Enter initial balance"); double bal = obj.nextDouble(); if ((wit <= bal-0.5) && (wit % 5 == 0) && (wit > 0)) { System.out.println(String.format("%.2f", bal-wit-0.5)); } else { System.out.println(String.format("%.2f", bal)); } } }
Why am I getting wrong answer here? What did I overlook?
This piece of code produces the desired results in my local computer just fine.