Each of the two food stores, A and B, of the same company has a list of products that
are available in its stock. We assume that the standard input contains NA records for food store A
and NB records for food store B. Each record describes the code of a product (integer), its name
(string of characters), its expiration date (three integers), and its quantity (integer) available in
stock in its corresponding food store. Both food stores use the same codes for the same products,
which have the same expiration date, but do not necessarily have the same products in their
stocks. We assume that the products of a given food store are sorted in increasing order on their
codes. The two food stores decide to merge their stocks.
1. Propose a storage structure representing the state of each of the food store in memory.
2. Write a C++ program that reads the information associated with all the products of a
food store and saves them in the storage structure provided above. Then, your program
should accomplish each of the following tasks:
2
- Returns the code of the product that has the largest quantity.
- Returns the code of the product that has the smallest quantity.
- Checks whether a given product identified by its name or code is still valid, i.e., its
date of expiration has not been reached yet.
- Checks whether a given product identified by its code or name exits in a given food
store. We assume that the id number of food store A is 1 while the id number of food
store B is 2.
- Merges the products of the two food stores such that:
• The quantity of a product is the sum of its quantities in the stocks of both food
stores.
• All records are sorted in increasing order on the codes of the products.
- Outputs the information of a product identified by its code or name.
Note that it is necessary that your C++ program provide a user with a menu that enables them
to repetitively run one of the above-mentioned operations of their choice.
Bigojac2000 0 Newbie Poster
NathanOliver 429 Veteran Poster Featured Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.