ATM JAVA Code : Wrong Answer

import java.io.*;

public class ATM{

public static void main(String args[]){
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); 
		float bankCharges = 0.50f;
		String values=null;
		try{
			values = br.readLine();
			String [] split = values.split(" ");
			float withdraw = Float.parseFloat(split[0]); 
			float amount = Float.parseFloat(split[1]);
			if(withdraw>amount)
				System.out.println(amount);
			else if (withdraw+bankCharges<=amount)
			{
				if(withdraw % 5 == 0){
					amount=amount-(withdraw+bankCharges);
					System.out.println(amount);
				}
				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.

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:
http://www.codechef.com/viewsolution/4316657

the class can be public if it is called Main