in reply to Check this code please?

I bet just before the assignment was set, recent classes dealt with loops and arrays. The intent is to have you use them in your solution.

As Occam said: Entia non sunt multiplicanda praeter necessitatem.