Question: Write a menu-driven program that updates the binary inventory file, inventory.dat. The file is composed of records based on the following structure: const int DESC_SIZE

Write a menu-driven program that updates the binary inventory file, inventory.dat. The file is composed of records based on the following structure:

const int DESC_SIZE = 40;

struct Product

{

long prodNum;

char prodName[DESC_SIZE];

double price; int qty;

};

Requirements 1. Use a menu-driven program that implements the following commands:

a. Display product inventory file

b. Display a particular product

c. Modify a product

d. Exit the program

2. Implement the following functions:

a. int showMenu();

Displays the menu Inputs the users selection Validates the users selection

b. void printFile (fstream&); Clear the eof flag Seek the first record (record 0) Use an eof loop to read the file into a Product record and display the fields to the screen Use a counter in your loop to count and display the record number

c. void displayRecord( fstream&); Input the users record number selection Clear the eof flag Seek the first record (record 0) Seek the indicated record number

Read the file and displays the product record to the screen

d. void modifyRecord (fstream&);

Input the users record number selection Input new values for the selected record number Clear the eof flag Seek the first record (record 0) Seek the indicated record number

Write the new values to file to replace the existing data

3. Main program uses a while loop with embedded switch statement to call appropriate functions based on menu choice.

4. All operations must access the file do NOT use an array.

5. Output must be labelled and easy to read.

6. Program must be documented with the following: Name, Date, Program Name, and Description.

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!