Question
Use a value of 5 to seed the random number generator. For the first group, using a for loop, generate and display a series of
Use a value of 5 to seed the random number generator.
For the first group, using a for loop, generate and display a series of 15 random numbers between 70 and 100. The values should be neatly displayed on a single line. For each random number that is generated, determine what range the number falls into and increment a counter for that specific range. Use the following ranges for this program:
100 99 - 90 89 - 80 79 - 70
After the 15 random numbers have been generated and displayed, display the counts for each range. Each count should be displayed on a separate line with a descriptive label. The last digit of each count should be lined up.
For the second group, repeat the basic process that was used for the first group. However, rather than using a for loop, use a while loop.
For the third group, repeat the basic process that was used for the first and second groups. However, use a do while loop.
Symbolic Constants
The program MUST use at least three symbolic constants:
- an integer that represents the number of random values to be generated in each group. Use 15.
- an integer that represents the highest random value to generate. Use 100.
- an integer that represents the smallest random value to generate. Use 70.
Program Requirements
-
Make sure to seed the random number generator by calling the srand function. This MUST be done in main before calling the rand function. The file that is handed in for grading must use srand(5);.
-
Make and use meaningful variable names.
-
Make sure to actually use the symbolic constants that are created.
-
Be sure to #include
-
The program MUST be fully documented according to the documentation standards on the course website. Include line documentation. There is no need to document every single line, but logical "chunks" of code should be preceded by a line or two that describes what the "chunk" of code does.
-
Hand in a copy of the source code (CPP file) using Blackboard.
Output
Using srand(5); on Windows PC
Group 1 93 88 80 91 78 97 96 80 76 98 100 88 87 93 93 100 count: 1 90s count: 7 80s count: 5 70s count: 2 Group 2 99 98 89 99 92 94 88 77 71 90 80 82 88 84 70 100 count: 0 90s count: 6 80s count: 6 70s count: 3 Group 3 99 72 100 91 100 84 76 88 80 98 98 98 81 85 88 100 count: 2 90s count: 5 80s count: 6 70s count: 2
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started