using c++
Write a program that uses a structure to store the followinginventory information in a Binary file and access it using RandomAccess Method:
Item description
Quantity on hand
Wholesale cost
Retail cost
Date added to inventory
The program should have a menu that allows the user to performthe following tasks:
Add new records to the file
Display any record in the file
Change any record in the file
For data file opening logic, you may use the code segment below:This segment tries to open an existing file, if the file does notexist, it creates new one. Please note that your data file nameshould 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;
}
}
test case:
Inventory Program Menu 1. ADD NEW Record 2. DISPLAY Record 3. MODIFY Record 4. EXIT Programplease enter selection (1 – 4) : 1Enter the NEW Record Data:Desciption: CoffeeQuantity: 20Wholesale Price: $10Retail Price: $15Date Added: 02022018Inventory Program Menu 1. ADD NEW Record 2. DISPLAY Record 3. MODIFY Record 4. EXIT Programplease enter selection (1 – 4) : 2Which Record to DISPLAY:Please choose one of the following… 1 to 1 : 1Description: CoffeeQuantity: 20Wholesale Price: $10.00Retail Price: $15.00Date: 02022018Inventory Program Menu 1. ADD NEW Record 2. DISPLAY Record 3. MODIFY Record 4. EXIT Programplease enter selection (1 – 4) : 1Enter the NEW Record Data:Desciption: TEaQuantity: 30Wholesale Price: $30Retail Price: $40Date Added: 03032018Inventory Program Menu 1. ADD NEW Record 2. DISPLAY Record 3. MODIFY Record 4. EXIT Programplease enter selection (1 – 4) : 2Which Record to DISPLAY:Please choose one of the following… 1 to 2 : 2Description: TEaQuantity: 30Wholesale Price: $30.00Retail Price: $40.00Date: 03032018Inventory Program Menu 1. ADD NEW Record 2. DISPLAY Record 3. MODIFY Record 4. EXIT Programplease enter selection (1 – 4) : 3Which record to MODIFY:Please choose one of the following… 1 to 2 : 2Description: TEaQuantity: 30Wholesale Price: $30.00Retail Price: $40.00Date: 03032018Enter MODIFY Data:Desciption: TEa PowderQuantity: 10Wholesale Price: $10Retail Price: $15Date Added: 03032017Inventory Program Menu 1. ADD NEW Record 2. DISPLAY Record 3. MODIFY Record 4. EXIT Programplease enter selection (1 – 4) : 2Which Record to DISPLAY:Please choose one of the following… 1 to 2 : 2Description: TEa PowderQuantity: 10Wholesale Price: $10.00Retail Price: $15.00Date: 03032017Inventory Program Menu 1. ADD NEW Record 2. DISPLAY Record 3. MODIFY Record 4. EXIT Programplease enter selection (1 – 4) : 4 Thank you!Test CAse2:Inventory Program Menu 1. ADD NEW Record 2. DISPLAY Record 3. MODIFY Record 4. EXIT Programplease enter selection (1 – 4) : 5Please enter a valid choice (1 – 4): 4Thank you!
Expert Answer
Answer to using c++ Write a program that uses a structure to store the following inventory information in a Binary file and access…