Question: Inventory Program Write a program that uses a structure to store the following inventory information in a Binary file and access it using Random Access

Inventory Program

Write a program that uses a structure to store the following inventory information in a Binary file and access it using Random Access Method:

Item description

Quantity on hand

Wholesale cost

Retail cost

Date added to inventory

------------------------------------------------------------

Structure:

struct InventoryData

{

char iDesc[50];

int quantity;

double wCost;

double rCost;

char date[15];

};

---------------------------------------------------

The program should have a menu that allows the user to perform the following tasks:

Add new records to the file

Display any record in the file

Change any record in the file

-------------------------------------------------------

Function for menu:

void menu()

{

cout << "Inventory Program Menu" << endl;

cout << " 1. ADD NEW Record" << endl;

cout << " 2. DISPLAY Record" << endl;

cout << " 3. MODIFY Record" << endl;

cout << " 4. EXIT Program" << endl;

cout << "please enter selection(1 - 4) : ";

}

-----------------------------------------------------------------

For exact menu option text please see the test cases below:

Inventory Program Menu 1. ADD NEW Record 2. DISPLAY Record 3. MODIFY Record 4. EXIT Program please enter selection (1 - 4) : 1 Enter the NEW Record Data: Desciption: Coffee Quantity: 20 Wholesale Price: $10 Retail Price: $15 Date Added: 02022018 Inventory Program Menu 1. ADD NEW Record 2. DISPLAY Record 3. MODIFY Record 4. EXIT Program please enter selection (1 - 4) : 2 Which Record to DISPLAY: Please choose one of the following... 1 to 1 : 1 <-------- Must incorporate this part of the program! I'm not sure how to count the records so please help me out! Description: Coffee Quantity: 20 Wholesale Price: $10.00 Retail Price: $15.00 Date: 02022018 Inventory Program Menu 1. ADD NEW Record 2. DISPLAY Record 3. MODIFY Record 4. EXIT Program please enter selection (1 - 4) : 1 Enter the NEW Record Data: Desciption: TEa Quantity: 30 Wholesale Price: $30 Retail Price: $40 Date Added: 03032018 Inventory Program Menu 1. ADD NEW Record 2. DISPLAY Record 3. MODIFY Record 4. EXIT Program please enter selection (1 - 4) : 2 Which Record to DISPLAY: Please choose one of the following... 1 to 2 : 2 <-------- Having a hard time trying to incorporate this, but must be inputted accurately! Description: TEa Quantity: 30 Wholesale Price: $30.00 Retail Price: $40.00 Date: 03032018 Inventory Program Menu 1. ADD NEW Record 2. DISPLAY Record 3. MODIFY Record 4. EXIT Program please enter selection (1 - 4) : 3 Which record to MODIFY: Please choose one of the following... 1 to 2 : 2 Description: TEa Quantity: 30 Wholesale Price: $30.00 Retail Price: $40.00 Date: 03032018 Enter MODIFY Data: Desciption: TEa Powder Quantity: 10 Wholesale Price: $10 Retail Price: $15 Date Added: 03032017 Inventory Program Menu 1. ADD NEW Record 2. DISPLAY Record 3. MODIFY Record 4. EXIT Program please enter selection (1 - 4) : 2 Which Record to DISPLAY: Please choose one of the following... 1 to 2 : 2 Description: TEa Powder Quantity: 10 Wholesale Price: $10.00 Retail Price: $15.00 Date: 03032017 Inventory Program Menu 1. ADD NEW Record 2. DISPLAY Record 3. MODIFY Record 4. EXIT Program please enter selection (1 - 4) : 4 Thank you! Test CAse2: Inventory Program Menu 1. ADD NEW Record 2. DISPLAY Record 3. MODIFY Record 4. EXIT Program please enter selection (1 - 4) : 5 Please enter a valid choice (1 - 4): 4 Thank you! 

--------------------------------------------------------------------------------------------------------------------

For data file opening logic, you may use the code segment below: This segment tries to open an existing file, if the file does not exist, it creates new one. Please note that your data file name should be inventory.dat

-------------------------------------------------------------------------------------------------------------------

fstream inventory; inventory.open("inventory.dat", ios::out|ios::in|ios::binary ); if (inventory.fail()) { inventory.open("inventory.dat", ios::out|ios::in | ios::binary| ios::trunc ); if (inventory.fail()) { cout << "Error opening file...."; return 0; } }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!