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: [?2004l
Main Menu:
1. Print items in the original order
2. Sort menu
3. Exit
Enter your choice: 1
Inventory:
ID Name Quantity Price
1234567890 Apple 500.99
214748364700
000
000
000
000
000
000
000
000
000
000
000
000
000
000
000
000
000
000
000
000
000
000
000
000
000
000
000
000
000
000
000
000
000
000
000
000
000
000
000
000
000
000
000
000
000
000
000
000
000
000
000
000
000
000
000
000
000
000
000
000
000
000
000
000
000
000
000
000
000
000
000
000
000
000
000
000
000
000
000
000
000
000
000
000
000
000
000
000
000
000
000
000
000
000
000
000
000
000
Main Menu:
1. Print items in the original order
2. Sort menu
3. Exit
Enter your choice: 4
Draft version -
4
main.cpp
Run
O Debug
inventory.txt :
Stop
1234567890 Apple 500.99
2234567890 Banana 300.59
3234567890 Orange 601.29
4234567890 Grapes 40,2.99
5234567890 Mango 201.99 Main Menu:
Print items in the original order
Sort menu
Exit
Enter your choice: 1// Function to print the inventory
void printInventory(InventoryItem* pInventory[], int numItems){
cout <<"
Inventory:
";
cout <<"ID\t\tName\t\tQuantity\tPrice
";
for (int i =0; i < numItems; i++){
cout << pInventory[i]->itemId <<"??t
<< pInventory[i]->name <<"\t\t"
<< pInventory[i]->quantity <<"\t\t"
<< pInventory[i]->price <<"
";
< pInventory[i]->price
// Function to swap two inventory item pointers
void swap(InventoryItem*& a, InventoryItem*& b){
InventoryItem* temp = a;
a = b;
b = temp;
}
// Function to sort inventory based on the user's choice
void sortInventory(InventoryItem* pInventory[], int numItems, SortOption option){
for (int i =0; i < numItems -1; i++){
for (int j =0; j < numItems - i -1; j++){
bool swapNeeded = false;
switch (option){
case ID:
swapNeeded = pInventory[j]->itemId < pInventory[j +1]->itemId;
break;
case NAME:
swapNeeded = pInventory[j]->name < pInventory[j +1]->name;
break;
case QUANTITY:
swapNeeded = pInventory[j]->quantity < pInventory[j +1]->quantity;
break;
case PRICE:
swapNeeded = pInventory[j]->price < pInventory[j +1]->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 sortMenu(InventoryItem* pInventory[], int numItems){
int sortOption =0;
do {
cout <<"
Sort Men

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!