Before I try and help you out, can you clarify if this exercise is part of coursework or homework? If so we have some policies on this forum that we can give you pointers but no solutions:
In case this is not part of homework, just tell us and we can provide a solution rather than tips. We rely on your honesty to tell us what it's used for