Question: C++ INSTRUCTIONS Write a class that can be used to generate text files that contain a requested number of random numbers. Use psuedo-random number generation

C++

INSTRUCTIONS

Write a class that can be used to generate text files that contain a requested number of random numbers. Use psuedo-random number generation techniques and take a filename from the user to create the file. Place a newline after each number in the file except for the last number. After writing the number generation method, create a method that valides the format of the file by reading in the numbers from a provided filename and counting the number of numeric entries that appear. When generating the random numbers, create an array on the heap to temporarily hold the numbers as they are created. After the array has been populated, transfer the numbers to the file with file IO operations. Close the file and deallocate the memory from the heap. Be sure to check to make sure the file is opened before reading or writing in any of your methods.

Use the following driver code and specification file to begin your program. Make your output model the provided screen shot.

DRIVER

#include

#include "A10S-NumberFileGeneratorClass-Specification.h"

using namespace std;

#defineFILE_NAME_500 "NumFile500.txt"

#defineFILE_NAME_5K "NumFile5K.txt"

#defineFILE_NAME_25K "NumFile25K.txt"

#defineFILE_NAME_100K "NumFile100K.txt"

#defineLIST_SIZE_500 500

#defineLIST_SIZE_5K 5000

#defineLIST_SIZE_25K 25000

#defineLIST_SIZE_100K 100000

int main() {

// instantiate the class

NumberFileGenerator myFileGenerator;

cout

// generate a data file with 500 random numbers & validate

myFileGenerator.GenerateNumberFile(FILE_NAME_500, LIST_SIZE_500);

if(myFileGenerator.ValidateDataFile(FILE_NAME_500) == LIST_SIZE_500) {

cout

}

// generate a data file with 5000 random numbers

myFileGenerator.GenerateNumberFile(FILE_NAME_5K, LIST_SIZE_5K);

if(myFileGenerator.ValidateDataFile(FILE_NAME_5K) == LIST_SIZE_5K) {

cout

}

// generate a data file with 25000 random numbers

myFileGenerator.GenerateNumberFile(FILE_NAME_25K, LIST_SIZE_25K);

if(myFileGenerator.ValidateDataFile(FILE_NAME_25K) == LIST_SIZE_25K) {

cout

}

// generate a data file with 100000 random numbers

myFileGenerator.GenerateNumberFile(FILE_NAME_100K, LIST_SIZE_100K);

if(myFileGenerator.ValidateDataFile(FILE_NAME_100K) == LIST_SIZE_100K) {

cout

}

return 0;

}

SPECIFICATION

#ifndef__NUMBER_FILE_GENERATOR__

#define__NUMBER_FILE_GENERATOR__

#include

#include

using namespace std;

#include // for rand() srand()

#include // for time()

#ifndef__TRUE_FALSE__

#define __TRUE_FALSE__

#define TRUE 1

#define FALSE 0

#endif

#define SUCCESS 0

#defineFILE_CANT_OPEN 1

classNumberFileGenerator {

private:

int* numberArrayHolder; // used to hold memory allocated

// from the heap where the numbers

// will be stored before being

// committed to the file system

public:

// constructor

NumberFileGenerator();

// creates a file with the specified name containing

// the requests number of pseudo-random numbers seperated

// by newline characters

int GenerateNumberFile(char* fileName, long howMany);

// validate the format of a random number file and return

// the number of integers that could be read from the file

long ValidateDataFile(char* fileName);

};

#endif

SAMPLE OUTPUT

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!