Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

For this assignment, write a program that will generate random numbers in the ra

ID: 3669867 • Letter: F

Question

For this assignment, write a program that will generate random numbers in the range of 50-100 and count how many fall into particular ranges.

Processing:

The program should first seed the random number generator. This is done one time in the program. Use srand(0).

Next, generate and display a series of 10 random numbers between 50 and 100. There are several ways to ensure that a random number falls between 50 and 100. One possibility is to use the following formula:

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:

After the 10 random numbers have been generated, display the counts for each range. Also, ask the user if they want to generate another series of 10 numbers. Accept upper or lower case “y” to continue. Anything else means end the program.

Symbolic Constants:

The program should use at least three symbolic constants. They should be:

an integer that represents the number of random values to be generated in each series. Use 10.

an integer that represents the highest random value to generate. Use 100.

an integer that represents the smallest random value to generate. Use 50.

Processing Requirements:

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.

Output:

Extra Credit:

For up to 5 points of extra credit, add code that will calculate and display the cumulative number of values in each range after the user quits, and print a bar graph of the values.

The display does not have to be exactly like what is shown in the output that is below, but it should be neat and easy to read.

Extra Credit Output:

Explanation / Answer

Desired Program is given below

#include<iostream>
#include<cmath>
#include<ctime>
#include<cstdlib>
using namespace std;

int main()
{
   int randNumArray[10];
   int elementInFiftys;
   int elementInSixtys;
   int elementInSeventys;
   int elementsInEightys;
   int elementsInNintys;
   int totalelementInFiftys = 0;
   int totalelementInSixtys = 0;
   int totalelementInSeventys = 0;
   int totalelementsInEightys = 0;
   int totalelementsInNintys = 0;


   srand(time(NULL));
   int Set = 1;
  
   char a;
  
   do
   {
       elementInFiftys = 0;
        elementInSixtys = 0;
        elementInSeventys = 0;
        elementsInEightys = 0;
        elementsInNintys = 0;
      
   cout<<"Set "<<Set<<endl<<endl;
  
   for(int i =0;i<10;i++)
   {
       randNumArray[i] = 50 + (rand() % (int)(100 - 50 + 1));
       cout<<randNumArray[i]<<endl;
   }
  
   cout<<endl;
  
   for(int j = 0; j<50; j++)
   {
       if(randNumArray[j]>= 50 && randNumArray[j]<60)
       {
           elementInFiftys++;
       }
      
       if(randNumArray[j]>= 60 && randNumArray[j]<70)
       {
           elementInSixtys++;
       }
      
       if(randNumArray[j]>= 70 && randNumArray[j]<80)
       {
           elementInSeventys++;
       }
      
       if(randNumArray[j]>= 80 && randNumArray[j]<90)
       {
           elementsInEightys++;
       }
      
       if(randNumArray[j]>= 90 && randNumArray[j]<=100)
       {
           elementsInNintys++;
       }          
   }
  
   cout<<"90s + count: "<<elementsInNintys<<" ";
   cout<<"80s count: "<<elementsInEightys<<" ";
   cout<<"70s count: "<<elementInSeventys<<" ";
   cout<<"60s count: "<<elementInSixtys<<" ";
   cout<<"Less than 60s: "<<elementInFiftys<<" "<<endl<<endl;
  
   totalelementsInNintys += elementsInNintys;
   totalelementsInEightys += elementsInEightys;
   totalelementInSeventys += elementInSeventys;
   totalelementInSixtys += elementInSixtys;
   totalelementInFiftys += elementInFiftys;
  
   cout<<"Do you want to generate another set?"<<endl;
   cin>>a;
   cout<<endl;
  
   Set++;
   }
   while(a == 'Y' || a == 'y');
  
   cout<<"Overall Counts"<<endl;
  
   cout<<"90s + count: "<<totalelementsInNintys<<"   ";
   for(int s =0; s<totalelementsInNintys;s++)
       cout<<"*";
   cout<<endl;
  
   cout<<"80s count: "<<totalelementsInEightys<<"   ";
   for(int s =0; s<totalelementsInEightys;s++)
       cout<<"*";
   cout<<endl;
  
   cout<<"70s count: "<<totalelementInSeventys<<"   ";
   for(int s =0; s<totalelementInSeventys;s++)
       cout<<"*";
   cout<<endl;
  
   cout<<"60s count: "<<totalelementInSixtys<<"   ";
   for(int s =0; s<totalelementInSixtys;s++)
       cout<<"*";
   cout<<endl;
  
   cout<<"Less than 60s: "<<totalelementInFiftys<<"   ";
   for(int s =0; s<totalelementInFiftys;s++)
       cout<<"*";
   cout<<endl;  
  
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote