Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

C++

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

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

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

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; } }

Output has to be the same:

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 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 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! 

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

AWS Certified Database Study Guide Specialty DBS-C01 Exam

Authors: Matheus Arrais, Rene Martinez Bravet, Leonardo Ciccone, Angie Nobre Cocharero, Erika Kurauchi, Hugo Rozestraten

1st Edition

1119778956, 978-1119778950

Students also viewed these Databases questions