Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Design And SQL For DB2

Authors: James Cooper

1st Edition

1583473572, 978-1583473573

Students also viewed these Databases questions

Question

Do you currently have a team agreement?

Answered: 1 week ago

Question

How will the members be held accountable?

Answered: 1 week ago