Runtime Error, memory issues perhaps?

atm
error
exception
rte
runtime

#1

Hey Guys,

I wrote code for the ATM practice problem http://www.codechef.com/problems/HS08TEST

I am quite confident my code is correct. However, I get a run time error. Any idea why?

Here is my code


import java.io.*;
import java.util.*;
import java.text.*;

class ATM {
	
	private static final float CHARGE = 0.50f;
	private float balance;
	
	public ATM(float myBal) {
		balance = myBal;
	}
	
	public void withdraw(float x) {
		if ((x % 5) == 0) {
			if (x+ CHARGE <= balance) {
				balance = balance - x - CHARGE;
			} 
		}
	}
	
	public void printBalance() {
		DecimalFormat df = new DecimalFormat("0.00");
		System.out.print(df.format(balance));
	}
	
	public static void main(String[] args) throws Exception{
		
		BufferedReader aReader = new BufferedReader(new InputStreamReader(System.in));
		String str = null;
		try {
			str = aReader.readLine();
		} catch (Exception e) {
			System.out.println(e.getMessage());
			System.exit(1);
		} finally {
			aReader.close();
		}
		StringTokenizer tokenizer = new StringTokenizer(str);
		float toWithdraw = Float.parseFloat(tokenizer.nextToken());
		float balance = Float.parseFloat(tokenizer.nextToken());
		ATM anATM = new ATM(balance);
		anATM.withdraw(toWithdraw);
		anATM.printBalance(); 
		
	
	}
}

#2

Got it , for some reason this thing doesnt like the finally block
so i removed it