Can you please give me some ideas on how to start, i have no clue!!!!

Create a program that will test the random number generator by generating 10,000 random numbers and graphing their frequency in a histogram. This program should produce numbers from 1 to 100 and should display a scale of one notch per 10 occurrences in the histogram.

Example:

Welcome to the Random Number Generator Tester

===================================

Range Frequency (1 line = 10 occurances)

===================================

1-10 |||||||||||||||||||||||||||||||||||||||||||||||||||||||||

11-20 |||||||||||||||||||||||||||||||||||||||||||||||||||||

21-30 |||||||||||||||||||||||||||||||||||||||||||||||

31-40 |||||||||||||||||||||||||||||||||||||||||||||||||||||||

41-50 ||||||||||||||||||||||||||||||||||||||||||||||||||||||

51-60 |||||||||||||||||||||||||||||||||||||||||||||

61-70 |||||||||||||||||||||||||||||||||

71-80 ||||||||||||||||||||||||||||||||||||||

81-90 ||||||||||||||||||||||||||||||||||||||||||||||||||

91-100 ||||||||||||||||||||||||||||||||||||||||||||||

you have to keep track of 10 ranges. Every time you generate a new random number check to see which of the 10 ranges it falls in and then increment that counter. Once you get that done and working right it should be not too difficult to print out the histogram.

The problem with that program is that the histogram isn't very pretty because, on average, with 10,000 random numbers each range will contain about 1000 numbers. And each line of the histogram will have about 100 '|' symbols.

Edited 7 Years Ago by Ancient Dragon: n/a

just create an array of 10 integers. Then create a loop from 0 to 10000. Inside that loop generate a random number. Then in a series of if statements find out which range the number is in and increment the corresponding counter.

Anyone with a football avatar should be able to do it, unless of course you are only in school to play sports :)

Edited 7 Years Ago by Ancient Dragon: n/a

This article has been dead for over six months. Start a new discussion instead.