

Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!


Due date : Friday, September 22, 2006 – beginning of class Description : You are to write two C++ programs. The first will be practice with stacks; the second will be practice with queues. Both will also involve linked lists Stack program : Develop a stack class using a linked list representation and integer data and use it in a program that requests postfix expressions from the user and evaluates them. The user should be able to enter as many expressions as he or she likes. Specifications: You may assume spaces between the individual elements of the expression. All input will be integral and nonnegative, though the answer may be negative. The answer should be integers, not floating-point numbers. You must be able to handle all 5 standard arithmetic integer operators. For this program, you may find it useful to investigate the atoi function. Queue program : Develop a queue class using a linked list representation and integer data and use it in a program to simulate a check-out line at a supermarket. Customers arrive in random integer intervals of 1 to x minutes. Also, each customer is serviced in random integer intervals of 1 to x minutes. Request a value for x at the beginning of the run. Run the supermarket simulation for a 12-hour day (720 minutes) using the following algorithm:
Where xx represents which customer, counting from 1 (not zero), and yy is the current time (in the range 1-720). At the end of the simulation, your program should print out the maximum number of customers in the queue at any one time, and the longest wait any one customer experienced. Note that the number of customers in the queue does not include the one being waited on, and the wait does not include service time. Don’t make up your own algorithm, please. Don’t use a queue of customers, just ints, that’s all you need if you do it as specified. General program requirements: Your stack and queue classes must be good ADT implementations. Do not allow the specifics of the application to impact the design and implementation of those classes. Make sure that your classes use good dynamic memory management (so they must have destructors, copy constructors and assignment operators). Submit your source files from the Suns using WebCT. Note that you should have at least three files (one .h and 2 .cpp) for each program. Name your files with clearly meaningful names (no main.cpp, please).