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

11. Inventory Program Write a program that uses a structure to store the followi

ID: 3620263 • Letter: 1

Question

11. Inventory Program
Write a program that uses a structure to store the following inventory data in a file:
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.
Input Validation: The program should not accept quantities, or wholesale or retail costs less than 0. The program should not accept dates that the programmer determines are unreasonable.

Explanation / Answer

#include #include using namespace std; // Declaration of InventoryItem structure struct InventoryItem { char desc[51]; //item description int qty; //quantity on hand float wholesale; //wholesale price float retail; //retail price }; //Function Prototypes int menu(); void AddRecord(fstream &); void DisplayRecord(fstream &);void ChangeRecord(fstream &); int main() { int choice; fstream inventory ("InventoryFile.dat", ios::out | ios::binary); InventoryItem record = {" ", 0, 0.0}; //writing the blank records for (int count = 0; count < 5; count++) { inventory.write(reinterpret_cast(&record), sizeof(record)); } inventory.close(); inventory.open("InventoryFile.dat", ios::out | ios::binary); do { choice = menu(); switch (choice) { case 1: AddRecord(inventory); break; case 2: DisplayRecord(inventory); break; case 3: ChangeRecord(inventory); break; case 4: cout
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Chat Now And Get Quote