That is, write a small and simplified version of the program first. When this works, add another feature. When this works, add some more stuff. Computer program syntax is demanding. Read the manual.
Computers always spit out something.
To help answer this question always give your computer program test cases . A test case is giving the computer program inputs for which you already know what the outputs should be. For example, if you reduce the spring constant of your ruler to a low value, the device should not move the ball much. Use a variety of test cases to judge if the computer model is spitting out reasonable numbers. Make your computer model flexible.