Home / Expert Answers / Computer Science / problem-1-random-sequence-create-a-class-that-returns-a-random-number-from-the-following-set-19-pa944

(Solved): Problem 1 (Random Sequence) Create a class that returns a random number from the following set, 19, ...



Problem 1 (Random Sequence) Create a class that returns a random number from the following set, 19,34,57,79,126. Loop 100,000 times with this procedure and print the frequency of each of the 5 numbers obtained. The following is the specification for the class. Specification class Prob1Random{ private: char *set; //The set of numbers to draw random numbers from Problem 1 (Random Sequence) Create a class that returns a random number from the following set, 19,34,57,79,126. Loop 100,000 times with this procedure and print the frequency of each of the 5 numbers obtained. The following is the specification for the class. Specification class Prob1Random{ private: char *set; //The set of numbers to draw random numbers from char nset; //The number of variables in the sequence int *freq; //Frequency of all the random numbers returned int numRand; //The total number of times the random number //function is called public: Prob1Random(const char,const char *);//Constructor ~Prob1Random(void); //Destructor char randFromSet(void); //Returns a random number from the set int *getFreq(void) const; //Returns the frequency histogram char *getSet(void) const; //Returns the set used int getNumRand(void) const; //Gets the number of times randFromSet //has been called }; Driver program to return a random sequence char n=5; char rndseq[]={19,34,57,79,126}; int ntimes=100000; Prob1Random a(n,rndseq); for(int i=1;i<=ntimes;i++){ a.randFromSet(); } int *x=a.getFreq(); char *y=a.getSet(); for(int i=0;i



We have an Answer from Expert

View Expert Answer

Expert Answer


We have an Answer from Expert

Buy This Answer $5

Place Order

We Provide Services Across The Globe