Question
Please use the following code given below to write another code with the following instructions give in the picture. please follow all the steps given.
Please use the following code given below to write another code with the following instructions give in the picture. please follow all the steps given.
Code: #include
Description: In assignment 1 you wrote a program that produced a file. For example, it may be A-3245 A 2344 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" & should get the number from the remainder of the line as a string, and push() that string into the stack You should tel 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 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 4 On line 1000 The system reads "D". It will try to pop() all three stacks. Depending on what happens in operations 8999 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
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