Suppose that we would like to implement a queue system for a commercial website. Given that the website offers 3 items for sale (or a list of items), each item has a limit quantity in stock. Implement a queue of customers, each customer can buy only a few number product among the available three items. Determine the item name, their quantity in stock; Specify a queue of n customers, each customer can buy k products from one item (k is different for each customer); Customers take turn to enter (enqueue) and leave (dequeue) the queue according to the FIFO order to purchase wanted products; If a customer successfully purchased products, then display a message and reduce the number of products in stock; otherwise, if the item has been run out, display a warning message. Implement the above problems in C/C++ using a Queue data structur. Write a main function for tes

C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter18: Stacks And Queues
Section: Chapter Questions
Problem 16PE: The implementation of a queue in an array, as given in this chapter, uses the variable count to...
icon
Related questions
Question

Suppose that we would like to implement a queue system for a commercial website. Given that the website offers 3 items for sale (or a list of items), each item has a limit quantity in stock. Implement a queue of customers, each customer can buy only a few number product among the available three items.

  • Determine the item name, their quantity in stock;
  • Specify a queue of n customers, each customer can buy k products from one item (k is different for each customer);
  • Customers take turn to enter (enqueue) and leave (dequeue) the queue according to the FIFO order to purchase wanted products;
  • If a customer successfully purchased products, then display a message and reduce the number of products in stock; otherwise, if the item has been run out, display a warning message.

Implement the above problems in C/C++ using a Queue data structur. Write a main function for testing all written functions.

Expert Solution
steps

Step by step

Solved in 2 steps with 3 images

Blurred answer
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning