Why are the costs that reduce the value of equipment not directly posted to the asset account Equipment?
January 3, 2018
Debate the issue of employee benefits during a time of falling profits and stock prices.
January 3, 2018

plement a well-structured C program to enable a shop to maintain its small items inventory. The item information is

implement a well-structured C program to enable a shop to maintain its small items inventory. The item information is
kept in a text-file, items.txt, of the form:
1007 5 30
1004 4 10
1003 3 20
1002 2 10
1006 4 40
1005 5 50
1001 1 70
1008 6 20
1010 4 90
1009 3 10
where each line of the text-file contains a unique itemID, the total item quantity available, and the price of item for 1 unit
in Saudi Riyals (SAR).
Note: The values given in the above file show that there is a total of 10 items. When the new item is added the default
value for the quantity is 10 which must be added by defining a constant.
The customer information is kept in a text-file, customerEntry.txt, of the form:
23 1007 3
44 1004 6
12 1007 1
23 1002 8
50 1007 1
50 1009 7
Where each line contains a customerID, the itemID, and the quantity of the item he purchased.
The values given in the file show that there are a total of 4 customers; e.g. the customer with ID 23 has purchased item
1007 with quantity 3 and item 1002 with quantity 8.
Your C program must have the following main menu:
1. Display Item Info for all Items
2. Display Item Info for a particular item
3. Display Customer Info for all customers
4. Purchase Item
5. Return Item
6. Add New Item
7. Delete Item
8. Exit
Please select your choice:
Page 2 of 4
Your program must loop as long as option 8 has not been selected. It must display an appropriate error message if an
invalid choice is entered. After executing each of the options 1 to 7, your program must pause and display the message:
“Press any key to continue . . .”. Your program must display the main menu after pressing any key. Each of the options
1 to 7 must be implemented in a separate function. The code for “Press any key to continue . . .” and the code for the
menu must also be implemented as separate functions.
The options must have the following behaviors:
Option 1: Display Item Info for all Items
It displays the item information of all items. The option must be implemented by reading directly from items.txt text-file.
It then waits for any key to be pressed before returning control to the main menu: Please select your choice: 1 ItemID Quantity Price Per Unit (SAR)
1007 5 30
1004 4 10
1003 3 20
1002 2 10
1006 4 40
1005 5 50
1001 1 70
1008 6 20
1010 4 90
1009 3 10
Press any key to continue . . .
Option 2: Display Item Info for a particular item
It prompts for and reads the itemID. It then searches for this itemID in the items.txt text-file. If the item is not found an
appropriate error message is displayed, otherwise; the item information is displayed. In both cases, the option waits for
any key to be pressed before returning control to the main menu.
Please select your choice: 2
Enter itemID: 1002
ItemID Quantity Price Per Unit (SAR) 1002 2 10
Press any key to continue . . .
Please select your choice: 2
Enter itemID: 1342
Error: Invalid item ID
Press Enter key to continue . . .
Page 3 of 4
Option 3: Display Customer Info for all customers
It displays the customer information of all customers. The option must be implemented by reading directly from
customerEntry.txt text-file. It then waits for any key to be pressed before returning control to the main menu:
Please select your choice: 3 CustomerID ItemID Quantity
23 1007 3
44 1004 6
12 1007 1
23 1002 8
50 1007 1
50 1009 7
Press any key to continue . . .
Option 4. Purchase Item
It prompts for and reads a customerID and the itemID of the item to purchase. Each of the following must cause an
appropriate error message to be displayed:
 The customerID is not in the range 10 to 60 inclusive.
 The itemID is not in items.txt
 There is not enough quantity available for the item to purchase.
Otherwise the contents of the text-file items.txt are copied into parallel arrays ItemID, ItemQuantity, and PricePerUnit
(count the number of lines in the text-file, and use this number as the array size). The number of purchased items for the
item is deccremented, and the items.txt text-file is then updated. Also a new customer entry, containing the customerID,
itemID, and the Quantity is appended to the customerEntry.txt file.
Control is returned to the main menu after pressing any key.
Option 5: Return Item
It prompts for and reads a customerID, itemID and the Quantity of the item to return. Each of the following must cause an
appropriate error message to be displayed:
 The customerID is not in the range 10 to 60 inclusive.
 The customerID, itemID and Quantity pair is not in customerEntry.txt (There may be multiple entries but search
for the first entry only).
Otherwise the contents of the text-file items.txt are copied into parallel arrays ItemID, ItemQuantity, and PricePerUnit
(count the number of lines in the text-file, and use this number as the array size). The number of returned items for the
item is incremented, and the items.txt text-file is then updated. The contents of customerEntry.txt are copied into
integer parallel arrays CustomerID, ReturnedItemID and Quantity (count the number of lines in the text-file, and use this
number as the array size), the customerEntry.txt file is then updated not to contain this pair entry.
Control is returned to the main menu after pressing any key.
Page 4 of 4
Option 6: Add New Item
It prompts for and reads the itemID and the price per unit of the new item. An appropriate error message must
be displayed if the itemID already exists in items.txt file; otherwise the new item entry is appended to items.txt
with a maximum quantity as defined by a constant.
Control is returned to the main menu after pressing any key.
Option 7: Delete Item
It prompts for and read the itemID to be deleted. Only items that have maximum quantity can be deleted. Any
of the following must cause an appropriate error message to be displayed:
 The itemID does not exist in items.txt file.
 The itemID exists in items.txt file but the quantity is not maximum.
Otherwise the contents of items.txt are copied into parallel arrays ItemID, ItemQuantity, and PricePerUnit (count the
number of lines in the text-file, and use this number as the array size) and then the items.txt file is updated not to contain
the deleted item entry.
Control is returned to the main menu after pressing any key.

 

"Are you looking for this answer? We can Help click Order Now"