Question: My output looks like: [ ? 2 0 0 4 l Main Menu: 1 . Print items in the original order 2 . Sort menu
My output looks like: l
Main Menu:
Print items in the original order
Sort menu
Exit
Enter your choice:
Inventory:
ID Name Quantity Price
Apple
Main Menu:
Print items in the original order
Sort menu
Exit
Enter your choice:
Draft version
main.cpp
Run
O Debug
inventory.txt :
Stop
Apple
Banana
Orange
Grapes
Mango Main Menu:
Print items in the original order
Sort menu
Exit
Enter your choice: Function to print the inventory
void printInventoryInventoryItem pInventory int numItems
cout
Inventory:
;
cout IDttNamettQuantitytPrice
;
for int i ; i numItems; i
cout pInventoryiitemId
pInventoryiname tt
pInventoryiquantity tt
pInventoryiprice
;
pInventoryiprice
Function to swap two inventory item pointers
void swapInventoryItem& a InventoryItem& b
InventoryItem temp a;
a b;
b temp;
Function to sort inventory based on the user's choice
void sortInventoryInventoryItem pInventory int numItems, SortOption option
for int i ; i numItems ; i
for int j ; j numItems i ; j
bool swapNeeded false;
switch option
case ID:
swapNeeded pInventoryjitemId pInventoryj itemId;
break;
case NAME:
swapNeeded pInventoryjname pInventoryj name;
break;
case QUANTITY:
swapNeeded pInventoryjquantity pInventoryj quantity;
break;
case PRICE:
swapNeeded pInventoryjprice pInventoryj price;
break;
default:
break;
Main Menu:
Print items in the original order
Sort menu
Exit
Enter your choice:
Function to display sort menu and call sorting functions
void sortMenuInventoryItem pInventory int numItems
int sortOption ;
do
cout
Sort Men
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
