ATM JAVA Code : Wrong Answer


public class ATM{

public static void main(String args[]){
		BufferedReader br = new BufferedReader(new InputStreamReader(; 
		float bankCharges = 0.50f;
		String values=null;
			values = br.readLine();
			String [] split = values.split(" ");
			float withdraw = Float.parseFloat(split[0]); 
			float amount = Float.parseFloat(split[1]);
			else if (withdraw+bankCharges<=amount)
				if(withdraw % 5 == 0){
				else System.out.println(amount);
		catch(Exception e){


Worng Answer is shown while submitting the code. To make the answer in the correct format , I’ve tried adding “0” in the “System.out.println”, as the output was in the string format.

1 Like

The class can not be public.

There is also some problem with the logic.

  1. You can not apply mod operator on float
  2. You also need to change a few else if statements.

Here I have corrected your solution:

the class can be public if it is called Main