We don’t give exercise solutions, but we do offer help and answer questions. Where are you getting stuck when you attempt to solve this yourself? We need more information in order to help you.
Is the code you have so far giving you a compile-time error, or a runtime error, or unexpected runtime behavior?