Please explain what "wont work" means: compiler error, execution error or wrong results.
Copy the contents of the console and paste it here that shows the problem and add some comments.

Please...