please dont copy from others
Posted: Sat Nov 27, 2021 2:25 pm
please dont copy from others
We will focus our attention on stacks, queues, and Linked lists. Q1) implement a stack and a queue classes. Keep these classes separate. Then either via a main program or another class, implement the code that will test your classes. The stack and/or queue abstractions must be implemented using Single linked lists. Q2) Write a simple application to manage an adding machine program, where the stack is sued to push and pop numbers and results. Your application should read in integer numbers and push them onto a stack and add them together whenever a plus sign is entered. It should support operations of: addition, subtraction, multiplication, and division. When the = is requested from the user, the result should be displayed. Design for a way for the user to cancel all entries (which will end up clearing the stack). Use your queue to manage the input received from the user. All data must be read a line at a time from standard-in, enqueue this data for future use. Then, retrieve it from the queue - to determine what operations the user has requested.
Sample input 1, 5, +, 2, -, -, 3, *, Program operations and output Read the input as a line of text Break the input into tokens (a token is a number or an operation), enqueue the tokens in to the queue Queue R F 3 2 5 1 + Process the user input using the stack, dequeue the elements from the queue and push the values into the stack, if encountered (+, -, *, or /), then pop two values from the stack, perform the operation and push the result back. If you encountered = print the result of the computation up to now to the user. Multiple images for the stack 5 1 2 6 4 Now the =, the print "4" and continue 5 1 2 6 3 4 12 Now the = the print "12" and finish
We will focus our attention on stacks, queues, and Linked lists. Q1) implement a stack and a queue classes. Keep these classes separate. Then either via a main program or another class, implement the code that will test your classes. The stack and/or queue abstractions must be implemented using Single linked lists. Q2) Write a simple application to manage an adding machine program, where the stack is sued to push and pop numbers and results. Your application should read in integer numbers and push them onto a stack and add them together whenever a plus sign is entered. It should support operations of: addition, subtraction, multiplication, and division. When the = is requested from the user, the result should be displayed. Design for a way for the user to cancel all entries (which will end up clearing the stack). Use your queue to manage the input received from the user. All data must be read a line at a time from standard-in, enqueue this data for future use. Then, retrieve it from the queue - to determine what operations the user has requested.
Sample input 1, 5, +, 2, -, -, 3, *, Program operations and output Read the input as a line of text Break the input into tokens (a token is a number or an operation), enqueue the tokens in to the queue Queue R F 3 2 5 1 + Process the user input using the stack, dequeue the elements from the queue and push the values into the stack, if encountered (+, -, *, or /), then pop two values from the stack, perform the operation and push the result back. If you encountered = print the result of the computation up to now to the user. Multiple images for the stack 5 1 2 6 4 Now the =, the print "4" and continue 5 1 2 6 3 4 12 Now the = the print "12" and finish