question archive Write a c++ code with comments "You are the manager of a supermarket who has decided to automate the regular sales and inventory report generation process

Write a c++ code with comments "You are the manager of a supermarket who has decided to automate the regular sales and inventory report generation process

Subject:Computer SciencePrice: Bought3

Write a c++ code with comments

"You are the manager of a supermarket who has decided to automate the regular sales and inventory report generation process. You have a file of items for sale containing item names, department, price and quantity in stock. You have a file of items sold containing the date of sale, item name and quantity sold. Write a C++ program using files and structures to produce the reports. Please write a program that conforms to the following requirements:

1. Create a structure called Item that contains the following data members: (4 points)

• name = cstring of 50 characters

• department - ctsring of 50 characters • quantity - integer

• price - double

2. Create a structure called Date that contains the following members: (2 points)

• day - integer

• month - integer • year - integer

3

• totalAmount - double

3. Create a structure called Sale that contains the following data members: (4 points):

• saleMonth - integer

• saleDay - integer

• saleYear - integer

• name - cstring of 50 characters • saleQuantity - integer

4. Open the file items.txt. The file will be in the following format (2 points):

numItems

Item1 * Department1 * quantityInStock1* price1

Item2 * Department2 * quantityInStock2* price2

.

.

.

ItemN * DepartmentN * quantityInStockN* priceN

5. The first line of the file is an integer N, representing the number of Items. The next 'N' lines of the file will consist of 4 pieces of data - the name of the item, followed by the department the item belongs to, the quantity of the item in stock, and the price of 1 unit of the item. These are separated by a *.

6. Create a dynamic array of 'N' items. Read the values of the N items from the items.txt file and populate the array. (8 points)

7. Open the file sales.txt. This file will be in the following format (2 points):

numSales

M1/D1/Y1 * Item1 * saleQuantity1

M2/D2/Y2 * Item2 * saleQuantity2

.

.

.

MK/DK/YK * ItemK * saleQuantityK

8. The first line of the file is an integer K, representing the number of sales. The next 'K' lines, will each consist of the Date of sale, the name of the item sold, and the quantity sold. These are * separated as well.

9. Read in the number of sales K from sales.txt. Create a dynamic array of M Sales, and populate the structure variables with the data from the file. (8 points)

10. Declare an in-stack array of 30 Dates. You may assume that the sales.txt file will not contain more than 30 different dates. (5 points)

11. For every sale

• Subtract the sale quantity of the item from the number in stock for that item. (8 points)

• If the Date is not already in the Date array, add it in, and initialize the total amount to 0. (6 points)

4

 

• Add the amount for the sale (item price * sale quantity) to the date's total amount. (10 points)

• You may assume that if an item goes out of stock, it will no longer appear in the sales.txt file.

12. Open a file called summary.txt and write all the data - items and stock by department and sale amounts by date, as shown in the sample run. If an item has 0 units in stock, print "Out of Stock". (13 points)

13. The Departments are - Bakery, Dairy, Household, Meat and Seafood, Pantry, Produce, and Wine. You may assume that no other department would be in the items.txt file.

14. Close the files and delete the dynamic arrays (8 points).

15. Make sure your program is commented properly (5 points) "

 

pur-new-sol

Purchase A New Answer

Custom new solution created by our subject matter experts

GET A QUOTE

Related Questions