Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Having trouble getting my program to run correctly. Would like to see where I\'m

ID: 3569414 • Letter: H

Question

Having trouble getting my program to run correctly. Would like to see where I'm going wrong from an example. Specifically having troubles with getting it to work with a class as a seperate file (.h file).

Problem:

You are the owner of a hardware store and need to keep an inventory that can tell you what different tools you have, how many of each you have on hand and the cost of each one. Write a program with menu to process Random-Access File. The menu has several options. First option is to open a random-access file. The program should prompt the user to enter the name of the file. If the file does not exist, the program should create the file with 100 empty records. The second option is to display all the valid records in the random-access file. The third option is to ask user to enter data for a new record. If the record already exists in the same record number, the new record will overwrite the old record. The fourth option is to exit the program.

The Random-Access Data File keeps the inventory of a hardware store. The file stores the part number (or record number between 1 to100), the tool name, the quantity on hand, and the cost of each tool.

Requirements:

a)    Your program must produce the prompt and the output the same as given.

b)    Your program should create a class named HardwareData containing the record data. Make sure you create get and set functions for each class member data.

Sample Run:

Enter 1 for opening data file.

Enter 2 for listing all the records.

Enter 3 for entering new records.

Enter 4 to exit the program.

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

Choice: 1

Enter File name: Hardware.dat

File does not exist. Creating the data file.

Choice: 2

Record #              Hardware data name        Quantity        Cost

Choice: 3

Enter the part number (0-99, -1 to end input): 5

Enter tool name: Hammer

Enter part number: (0-99, -1 to end): 9

Enter tool name: Nails

Enter Quantity and Price: 1000 5.50

Enter part number: -1

Choice: 2

Record #             Hardwaredata name             Quantity         Price

5                              Hammer                              5                  7.99

9                              Nails                                   1000             5.50

Any assistance is appreciated. I cannot seem to get the class as a seperate file to work which is a requirement (it cannot all be one file).

Explanation / Answer

fstream hardware; hardware.open("hardware.dat" , ios::binary | ios::out); //Create 100 blank objects--------------------------------------------------------------- if (!hardware) { cerr
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote