For this program, you will ask the user to provide a range of values (from 1 to that number, inclusive) and how long of a number sequence you want to generate using that number range. You will then generate and save the sequence in an array. After that, you will count the number of times each number occurs in the sequence, and print the frequency of each number. Hints: You can use multiple arrays for this assignment. One array should hold the number sequence, and another could keep track of the frequencies of each numbe
Multiple Frequencies. In the last assignment, we calculated the frequency of
a coin flip. This required us to have two separate variables, which we used to record the number
of heads and tails. Now that we know about arrays, we can track the frequency of all numbers in
a randomly generated sequence.
For this program, you will ask the user to provide a range of values (from 1 to that number,
inclusive) and how long of a number sequence you want to generate using that number range.
You will then generate and save the sequence in an array. After that, you will count the number
of times each number occurs in the sequence, and print the frequency of each number.
Hints: You can use multiple arrays for this assignment. One array should hold the
number sequence, and another could keep track of the frequencies of each number.
Sample Output #1:
What’s the highest number you want to generate?: 5
How long of a number sequence do you want to generate?: 10
Okay, we’ll generate 10 number(s) ranging from 1 to 5!
1, 3, 1, 3, 3, 2, 4, 5, 1, 1,
Frequency:
1 occurs 40.00% of the time
2 occurs 10.00% of the time
3 occurs 30.00% of the time
4 occurs 10.00% of the time
5 occurs 10.00% of the time
Sample Output #2:
What’s the highest number you want to generate?: 3
How long of a number sequence do you want to generate?: 7
Okay, we’ll generate 7 number(s) ranging from 1 to 3!
1, 1, 3, 1, 3, 1, 3
Frequency:
1 occurs 57.14% of the time
2 occurs 0.00% of the time
3 occurs 42.85% of the time

Trending now
This is a popular solution!
Step by step
Solved in 2 steps









