Based on the description you gave, the desired output appears to be:
- the count (0..10000) of each number from one to six; and
- the average of all numbers.
So you’ll probably want something like this:
Number 1 occurred 1662 times.
Number 2 occurred 1676 times.
Number 3 occurred 1600 times.
Number 4 occurred 1696 times.
Number 5 occurred 1696 times.
Number 6 occurred 1670 times.
The average of all numbers was 3.5098.
That should be enough information for you to start coding. Feel free to come back and ask us specific questions about whatever code you come up with, we’ll be happy to help.
It may help to start with the following pseudo-code and work from there:
list = generate10000Numbers1To6()
create array count[1..6], initialise to zero
for number in list:
increment count[number]
sum = 0
for number in 1..6:
print "Number ", number, " occurred ", count[number], " times."
add count[number] * number to sum
print "The average of all numbers was ", sum / 10000, "."
3
solved Confused about this ‘lab’