Think first about the problem:
- what are the requirements?
- what are the inputs?
- what are the outputs?
- what are the transformation rules?
- what are the exceptions to any rules?
Once you have identified these you can start documenting the steps required to solve the problem. Only then can you start writing your code.