11 Nov





In this assignment, you will learn to write a program using linked list and tree data structure.



Remember that:

  1. All programs should be able to run on the lab’s computers.


  1. You must put the following information on the header of each text and source file you will be submitting in this assignment:


Student’s full name: Student’s ID:


Modification Date:


Purpose of this file (or program):


  1. Assignments that are not able to be compiled will result in zero mark given to the assignment.


  1. You must only use the C++ features that have already been covered in the lectures









Implement a menu-driven program for a hardware store that keeps the inventory records and also the sale transaction records for all its hardware items. Each hardware item is known with its barcode, description, price per unit, and quantity in hand. Use a suitable struct declaration to represent each item’s record. All the hardware items’ information is stored in a binary search tree to allow fast retrieval of a particular record. Each transaction record, which consists of invoice number, hardware item’s barcode, quantity purchased, and the total price, is stored in a linked list data structure.


The program starts by reading a filename containing a list of hardware items information. Construct a binary search tree to store all the hardware items read from this file with the barcode as the key. A menu should be displayed to allow a user to perform the following operations:


  • Update a hardware item’s quantity in hand or price per unit


  • Add a new hardware item


  • Display either all items or one item’s record by reading the barcode


  • Perform a sales transaction – allow several hardware items to be purchased


  • Remove a sales transaction based on invoice number


  • Edit a sales transaction by changing the hardware item’s barcode and/or quantity purchased


  • Display all sales transaction done together with a grand total sales amount



For each transaction performed, the program should prompt the user for a barcode and traverse the binary search tree to identify if the barcode exists. If it exists, prompt for the quantity and check it against the record stored in the binary search tree. No transaction should be done if the quantity in hand is not sufficient for the transaction.


If the record doesn’t exists, request if the user would like to add a new record and continue with the transaction, otherwise go back to main menu. If a transaction is done, add a new node containing the transaction details to the end of the linked list. The program should start with an empty linked list. A node should contain only one hardware item’s information. If the transaction involved more than one hardware item, then more than one node should be created and added to the linked list.


Before the program terminates, update the file containing the hardware items’ information and add to a transaction file all the transaction records in the list. Use functions to implement each option. Each data structure (linked list and binary search tree) must be implemented as a class and store each classes in separate

.cpp files with appropriate headers. Your driver program should be saved in a file named main.cpp.

Leave a comment

Posted by on November 11, 2016 in academic writing, Uncategorized



Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: