Passing Struct Arrays to Sort

Alright, so I'm going to be pretty straightforward about this, 1. I'm very new to using these forums and I have never posted before but I have used them to look up documentation and examples, and 2. it's homework for my programming class. I understand that I am not here to be spoon fed, on the contrary, I want to be guided in the right direction and presented with ideas and alternatives to my way of approaching this problem.

Write a C++ program that will allow a user to manage the inventory of a small store that sells various products of any type.
The inventory for the store will contain the following information for each product:

product name (i.e. “AppleiPhone3GS”, it will NOT contain spaces in it)
sku (stock keeping unit code, an integer)
quantity (how many of this product in stock)
price (in dollars and cents)

Note: Your program should be able to store up to 100 different products. You may assume that the skus will be unique (you do not need to check for this).

The program should first read the inventory from a text file named “inventory.dat”. This file will contain data for each product in the inventory in this order:
product name, sku, quantity, price.

It will contain up to 100 products.

Then, it should offer the user a menu with the following options:
1. Display the inventory sorted by sku.
2. Lookup a product by sku.
3. Lookup a product by name.
4. Quit

The program should perform the selected operation and then re-display the menu.

Do not change the menu numbers associated with the operations.
For the Display operation, display the information for each product on a separate line.

The values should line up in columns (use setw). Headers for the table are optional.

For the Lookup operations, label the output values (i.e. Name: AppleiPhone3GS, etc.).

If the product is not found, display an appropriate message.

Additional Requirements:
 The program must be modular (use top-down design), with significant work
done by functions. Each function should perform a single, well-defined task.

 Use a partially filled array of structures to store the inventory:
Use a counter variable to count the number of products that are read in from the file, and use this value as the size of the array for the search and sort functions.

 Your program should work for an input file with any number of products up to 100

 You MUST use binary search for Lookup by sku.
You can sort any unsorted container using std::sort.

Or use an automatically sorted container e.g. std::map or boost::multi_index_container
Last edited on
Registered users can post here. Sign in or register to post.