Have an array to tell you how many you need on each level. On the title screen you can add an even where you fill all the array values with the number of coins for each level.
The array width is the number of levels, and the height should be 2, one for the number of coins on the level, and the other to count the number the player got.
So each time the player gets a coin, you do
array.at(level, 1) = array.at(level, 1) + 1