Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Using visualstudio, write the C++ hide for this program Please fallow the instructions:- CSIS 223 Object-Oriented Programming with C+ Assign1 -Inventory Struct Inventory Struct Array

Using visualstudio, write the C++ hide for this program
Please fallow the instructions:-
image text in transcribed
image text in transcribed
CSIS 223 Object-Oriented Programming with C+ Assign1 -Inventory Struct Inventory Struct Array Lookup for Purchases Create the console program described in a suitable folder. Name the Project Assign01-Inventory Struct Copy the two input data files Inventory.txt and Purchases.oct to the project folder for processing. Use an array of record structs to hold the four inventory file values used to lookup data and process each purchase. Suggested variables and declarations #include using namespace std; struct txt- Notepad AX205 114.95 BL114 149.95 BY604 469.95 CL128 27.49 345 Holden_DoorGuard CL455 69.95 201 Entrex Static Hat DD889 14.25893 18 Phoenix Juicer 42 Harper_Sound Monitor Feld Convection_Oven inventoryType string itemCode; double itemPrice; Evans_FloorCote DQ114 18.49 81 Lerner Multi-Timer EG802 FAe5 FZ225 34.95 22 Zygran Humidifier Yard-eze-CarryA inventoryLookup(inventoryType inv[), int cnt, string code, int aty); i temOnHand; 7.95 137 12.4973 olden-video-Splitter string itemName; inventoryType void inventoryReport (inventoryType inv[]. int cnt); int main() inventoryType inventoryRec[ 20]; ray of Inventory records 361 inventoryType inventoryMatch; DQ114 // matched Inventory record 362 CL120215 363 FA105 12 364 F2225 21 itemCount purchaseCount e purchaseAmount dollarsign count of Inventory records / count of Purchases records 365 BY6841 l/ calculated amount total 366 BL114 2 EG802 16 368AX2853 369 DQ114 18 378 AX205 2 DD889 325 372 CL455 78 373 AX205 5 FA105 43 char string purchaseNum; string purchaseItem; Purchases file field values purchaseQty; 371 ifstream inventoryFile; ifstream purchasesFile; / Inventory input file / Purchases input file 374 Open the two input files and test both input streams. Issue an error message ! EG802 D0889 3 Load each of four data items in an inventory record into an Inventory record 378 FA1eS 74 379 FZ225 32 that forms a single entry in an array of structs (inventoryReel I). Count the3Y64 number of items loaded into this array and save this value (itemCountin order to control loops that will process and search the array in called routines (inventoryLookup() and inventory Report()). Close the Inventory input file. Display the count of inventory records (itemCount). Set up a while loop to process each record until end-of-file. Read the first purchase record into three variables. (Suggestion: Use a priming read to input the first field of the first record into the purchaseNum field on the line before the start of the while loop. Stream the other two purchases record fields into the purchaseltem and purchaseOty fields at the top of the loop. Repeat priming read at the very bottom of loop.) Within the while loop (after reading each entire purchase record): 1. Lookup and return a matched Inventory record (aventory Match) based on the matching input itemCode. Calculate total purchase amount for each purchase, multiplying matched item price by purchase quantity Display complete Purchase information in a stream to cout, including matched inventory information Increment the purchase count variable to track the number of Purchase records processed. 2. Locate the two input files (Inventory.txr and Purchases.toxt) in the same folder within the project where the Assign01-Inventory StructArray.cpp file resides. Test your input file check routine before copying the input running the program with actual file open routines. nput Esle not found ress any key te continue inventory lookup routine returns an entire matching inventory record struct. inventoryMatch- inventoryLookup(inventoryRec, itemCount, purchaseltem, purchaseoty); icall Lookup routine Necessary parameters include the name of the array (inventory Reel I), serving as a pointer to the starting address of the actual array, a count of actual number of records in the array (itemCnt) to limit array process- sing to filled locations (out of 20), the purchaseltem code to be located and matched within the routine, and the purchaseOoy to allow the lookup routine to subtract this number from the iemOnfand value for an item This subtraction adjusts the original array, since an array is always passed by re Use a loop within the inventoryLookup) routine to compare the purchase item code to each item Code in inventory array until a match is found. Declare a local int value to track the position within the array, incre- menting this position variable from O until a match is found in the array. Subtract the purchase quantity value from the ifies the position of the matching struct record to return for assignment to inventory Match. Use the values returned into the inventory Match record to provide the display record information needed for each purchase. Calculate the total purchase Amount for cach current purchase, multiplying the item Price in inventoryMatch by the input purchaseQty for this purchase. Display the line of information shown below for cach purchase. itemOnHand number at this position to update the inventory counts. This int value also ident 203BSpring Inventory loaded from file e itens leaded fron inventery inventory Rec// struct 21 12-49 play each record essed (along ehile loop unstil ) is reached Oldes Uideo Splitter 4469-95 1879.88 Fe ld Covection Ove 2 iters pure based. for loop within inventery Report) and-eze Carey 'y key to cantinu Close the Purchases file and display the number of purchase records processed (purchaseCount), Call the inventory Report) function to display inventory information with current items on hand values inventoryReport (inventoryRec, itemcnt) Prime the cout stream before any output to establish the fixed 2-digit decimal values for double call inventory Report display cout using namespace std; struct txt- Notepad AX205 114.95 BL114 149.95 BY604 469.95 CL128 27.49 345 Holden_DoorGuard CL455 69.95 201 Entrex Static Hat DD889 14.25893 18 Phoenix Juicer 42 Harper_Sound Monitor Feld Convection_Oven inventoryType string itemCode; double itemPrice; Evans_FloorCote DQ114 18.49 81 Lerner Multi-Timer EG802 FAe5 FZ225 34.95 22 Zygran Humidifier Yard-eze-CarryA inventoryLookup(inventoryType inv[), int cnt, string code, int aty); i temOnHand; 7.95 137 12.4973 olden-video-Splitter string itemName; inventoryType void inventoryReport (inventoryType inv[]. int cnt); int main() inventoryType inventoryRec[ 20]; ray of Inventory records 361 inventoryType inventoryMatch; DQ114 // matched Inventory record 362 CL120215 363 FA105 12 364 F2225 21 itemCount purchaseCount e purchaseAmount dollarsign count of Inventory records / count of Purchases records 365 BY6841 l/ calculated amount total 366 BL114 2 EG802 16 368AX2853 369 DQ114 18 378 AX205 2 DD889 325 372 CL455 78 373 AX205 5 FA105 43 char string purchaseNum; string purchaseItem; Purchases file field values purchaseQty; 371 ifstream inventoryFile; ifstream purchasesFile; / Inventory input file / Purchases input file 374 Open the two input files and test both input streams. Issue an error message ! EG802 D0889 3 Load each of four data items in an inventory record into an Inventory record 378 FA1eS 74 379 FZ225 32 that forms a single entry in an array of structs (inventoryReel I). Count the3Y64 number of items loaded into this array and save this value (itemCountin order to control loops that will process and search the array in called routines (inventoryLookup() and inventory Report()). Close the Inventory input file. Display the count of inventory records (itemCount). Set up a while loop to process each record until end-of-file. Read the first purchase record into three variables. (Suggestion: Use a priming read to input the first field of the first record into the purchaseNum field on the line before the start of the while loop. Stream the other two purchases record fields into the purchaseltem and purchaseOty fields at the top of the loop. Repeat priming read at the very bottom of loop.) Within the while loop (after reading each entire purchase record): 1. Lookup and return a matched Inventory record (aventory Match) based on the matching input itemCode. Calculate total purchase amount for each purchase, multiplying matched item price by purchase quantity Display complete Purchase information in a stream to cout, including matched inventory information Increment the purchase count variable to track the number of Purchase records processed. 2. Locate the two input files (Inventory.txr and Purchases.toxt) in the same folder within the project where the Assign01-Inventory StructArray.cpp file resides. Test your input file check routine before copying the input running the program with actual file open routines. nput Esle not found ress any key te continue inventory lookup routine returns an entire matching inventory record struct. inventoryMatch- inventoryLookup(inventoryRec, itemCount, purchaseltem, purchaseoty); icall Lookup routine Necessary parameters include the name of the array (inventory Reel I), serving as a pointer to the starting address of the actual array, a count of actual number of records in the array (itemCnt) to limit array process- sing to filled locations (out of 20), the purchaseltem code to be located and matched within the routine, and the purchaseOoy to allow the lookup routine to subtract this number from the iemOnfand value for an item This subtraction adjusts the original array, since an array is always passed by re Use a loop within the inventoryLookup) routine to compare the purchase item code to each item Code in inventory array until a match is found. Declare a local int value to track the position within the array, incre- menting this position variable from O until a match is found in the array. Subtract the purchase quantity value from the ifies the position of the matching struct record to return for assignment to inventory Match. Use the values returned into the inventory Match record to provide the display record information needed for each purchase. Calculate the total purchase Amount for cach current purchase, multiplying the item Price in inventoryMatch by the input purchaseQty for this purchase. Display the line of information shown below for cach purchase. itemOnHand number at this position to update the inventory counts. This int value also ident 203BSpring Inventory loaded from file e itens leaded fron inventery inventory Rec// struct 21 12-49 play each record essed (along ehile loop unstil ) is reached Oldes Uideo Splitter 4469-95 1879.88 Fe ld Covection Ove 2 iters pure based. for loop within inventery Report) and-eze Carey 'y key to cantinu Close the Purchases file and display the number of purchase records processed (purchaseCount), Call the inventory Report) function to display inventory information with current items on hand values inventoryReport (inventoryRec, itemcnt) Prime the cout stream before any output to establish the fixed 2-digit decimal values for double call inventory Report display cout

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

Step: 3

blur-text-image

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

Databases Illuminated

Authors: Catherine M. Ricardo, Susan D. Urban, Karen C. Davis

4th Edition

1284231585, 978-1284231588

More Books

Students also viewed these Databases questions

Question

e. 216 64X+5

Answered: 1 week ago

Question

Discuss cross-cultural differences in perception

Answered: 1 week ago

Question

Compare and contrast families and family roles across cultures

Answered: 1 week ago

Question

Compare and contrast sex and gender roles across cultures

Answered: 1 week ago