Can you explain what your problems are?
What is your design/logic for calculating the final output?

Also please wrap your posted code in code tags to preserver formatting. See:BB Code List - Java...