step 1: Get a pencil and paper (or use notepad or some other editor)
step 2: write down how you, personally, would do this by hand.
step 3: revise your steps until you have crystal clear directions that anyone can read, understand, and follow.
Don't even think about writing a single like of java code until you have done this.
Never ascribe to malice that which can be adequately explained by stupidity.