Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Please write the following code in C++ for Data Structures class. Please follow all the instructions in the picture below. Please write the program with
Please write the following code in C++ for Data Structures class. Please follow all the instructions in the picture below. Please write the program with zero warnings.
Description: Please write a short program, randomStream, that asks for the name of a file and a number, and produces a files satisfying the following conditions: The file name is the name given by the user (exactly--no added suffixes please) The number of lines in the file is exactly the same as the number provided by the user Each line is randomly* chosen to be one of the following lines: The letter "A" followed by a space and a randomly chosen number between INT_MIN and INTIMAX (for these to be defined, make sure your file #includes climits) The letter "D" The letter "P" The letter "E" The letter "C" The letter "S" Please make sure your program is well organized and well commented, and that you close the file before you exit. Your program must have a function, randomStream(std::string filename, int length) that actually produces the output file. "Be careful with your random number generators. You should use uniform int distribution (http://en.cppreference.com/w/cppumeric/random/uniform_int_distribution). You will need 2 different sequences of random numbers-one is between 0 and 5 (for the "A", "D", "P", "E", "C", "S"), the other between INT MIN and INT MAX (for the number to follow "A"). For example, you might run the program and have the following input/output: >randomStream Please input a filename: myfile.txt How many iterations: 10 If you were to look at the file, you might find the following contents: -2343324324 A 5453432 A-21324235345
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