I'll only deal with Problem 1 here since the rest should be clear to your from experimentation, once this bug is fixed.
It's Java: I think you need to convert long <-> double correctly. That would be why you're getting zero. Set up a very simple example where you just cast a doubledouble to a longlong and do vice versa with two separate variables, and see what happens. You should quickly enough findsee the problem. I believe the value is being truncated or somesuch.. You can alternatively try using long for everything. not to mention that you
You are also involving an integer literal (1000) in that expression as well, further complicating thingstype concerns. I suggest explicitly casting each term to double.
Once you have solved that, you should be able to answer the rest yourself, from the running codeand making 1000.0 i.e. a double.