Just a question first: Is this part of a course assignment? The type of question looks really like something you'd use in class
The reason I'm asking is that we're still happy to help you out, but in case of a homework assignment we do not provide solutions but only pointer as per our policy.
Please add the homework tag to this topic should this be the case and we'll take it from there.