Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please Use the following code to do the following homework. Please follow all instructions in the picture below and complete the assignment. Code: #include #include

Please Use the following code to do the following homework. Please follow all instructions in the picture below and complete the assignment.

Code:

#include #include #include #include #include #include using namespace std; default_random_engine generator((unsigned int)time(NULL)); uniform_int_distribution distribution(INT_MIN, INT_MAX); void randomStream(string filename, int length) { ofstream outFile(filename.c_str()); string characters = "ADPECS"; for (int i = 0; i > lines; randomStream(filename, lines); system("pause"); return 0; }

image text in transcribed

image text in transcribed

Description: In assignment 1 you wrote a program that produced a file. For example, it may be A-3245 A 2344 ODON A 344322 A-34 1.000 D Use the program to produce a file with 20 instructions. Please draw the sequence of 20 stacks (you may draw them similar to the way we draw them in class) as follows: Your stack should change at each line of the file, processing the file as if it was a set of instructions: . If the letter is "A", it should get the number from the remainder of the line as a string, and push() that string into the stack You should tell me the return value of the push() operations If the letter is a "P", it should peek() the stack. It must tell me the return value of the peek ( operations and the value passed back by reference . If the letter is a "D", it should check the top of the stack: It should pop the stack and tell me the return value and the value passed back by reference For example, using the sample file above: On line 1 The system reads "P" It will try to peek () the stack. Since it's empty, it will return FAILURE On line 2 The system reads "D". It will try to pop the stack. Since it's empty, it will return FAILURE On line 3 The system reads "A-3245". It will try to push() -3245 into the stack. This will succeed, and return SUCCESS On line 4 The system reads "A 2344". It will try to push() 2344 into the stack. This will succeed, and return SUCCESS On line 5 The system reads "D" It will try to pop() the stack. It will return SUCCESS The reference parameter will be 2344. Some time later On line 1000 The system reads "D". It will try to pop() all three stacks. Depending on what happens in operations 8...999 and the capacity, it may return SUCCESS or FAILURE. If it returns SUCCESS, then it will have some reference value Please hand in a Word (.docx) file with: The 20 operations produced by HW1 The sequence of pictures you drew (with operations and return values, as above)

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Databases On The Web Designing And Programming For Network Access

Authors: Patricia Ju

1st Edition

1558515100, 978-1558515109

More Books

Students also viewed these Databases questions