Things can be done in many different ways. Sometime, there is no right way or wrong way. But there are many ways due to different situation.
What I need to know is : What is the requirement:
Do you want:
What if there are more numbers, like 123456
Does the teachers always want to bring down all the numbers?
Please ask the teacher to explain it in all details?
Different requirements may need to be programmed different way. (Login might be different).
Sometime, it is difficult to modify the code if an extra requirement is not fit with the situation.
That is also the reason why I always ask you for alll detail for your requirement before I created simulations for you (or other users).
It does not matter what the teacher want. The important thing is write download all the detail specifications.
It is better if the teacher who need the simulation can draw some diagram/plot to explain what s/he really want,
and it will be even better if s/he can provide the reason. (May be we can find out a better solution).