atm problem,,I m stucked....help

import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main
{
	public static void main(String args[])throws Exception
	{
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		try
		{
		double w=Double.parseDouble(br.readLine());
		double b=Double.parseDouble(br.readLine());
		if(b>w)
		{
			if(w%5==0)
			{
			double a=w+0.50;
			if(b>=a)
				{
				System.out.printf("%.2f",b-w-0.50);
				}
			else 
				{
				System.out.printf("%.2f",b);
				}
			}
			else 
				{
				System.out.printf("%.2f",b);
				}
		}
		else
		{
				System.out.printf("%.2f",b);
			
		}
		}
		catch(Exception e)
		{
		e.printStackTrace();
      }finally{
        br.close();
      }
	}
		
}

what’s wrong with my answer, why is it giving wrong answer every time?

Try using \n after every print statement…

not necessarily after every printf but your output should totally match the given output in terms of formatting.So take care of that too.

import java.util.Scanner;
class ATM {
public static void main(String args[]){
Scanner in = new Scanner(System.in);

		System.out.println("Enter the initial account balance : ");
		double Y = in.nextDouble();
		
		
		System.out.println("Enter the amount of cash to withdraw : ");
		double X = in.nextDouble();
		if(X%5 != 0 ){
	
			System.out.println("Incorrect Withdrawal Amount (not multiple of 5)");
		}
		else{
			if (X>Y ){
				System.out.println(+Y);
			}else{
		
		double AB = Y-X-0.5;
		System.out.println("Your account balance left is : " +AB);
		}
		
	}

}
}

My program is also not running

Please read http://www.codechef.com/wiki/tutorial-inputoutput

Two things wrong here:

  1. There is no such word as “stucked”. Please read https://answers.yahoo.com/question/index?qid=20091210084223AA6Jzvo
  2. Your algorithm is wrong, you should check if “b > w+0.5”. because even if b == w+0.1, the transaction wouldn’t happen. Please read my solutions http://www.codechef.com/status/HS08TEST,chefkaushik94, even I had the same problem, its in python so readable