Use an array to store the data and use a loop to transverse through the array.
Everything afterwards is pretty trivial.