You’ve been asked to write a small menu driven inventory management system for a
ID: 3812516 • Letter: Y
Question
You’ve been asked to write a small menu driven inventory management system for a small convenient store. Your application shall maintain the following item information. Item information: Item ID – unsigned long Item name – string Item cost – float Quantity - int Following are the list of administrative functionality your application shall support initially: 1. Add new item to the inventory. This function will be used to add a single new item into the inventory management system. 2. Remove new item to the inventory 3. Print all item information in the store - This function will be used to display all items in the inventory. When this option is selected system shall print Item ID, Item name, Item cost and quantity. 4. Find item by ID – This function will be used to search item using an ID. If item exist print item information. If not display an error indicating item not found. 5. Find item by name – This function will be used to search item using name. If item exist print item information. If not display an error indicating item not found. Write a menu driven application in C++ which will print the following Inventory Management System Menu repeatedly until the Quit option is selected. Inventory Management System Menu 1. Add new item 2. Remove item 3. Print item list 4. Find item by ID 5. Find item by name 6. Quit Select: _ Note: Menu should repeatedly prompt to the user until the Quit option is selected by the user. Create data class for item and a container class for item list.
Explanation / Answer
#include<iostream>
using namespace std;
class item
{
private:
unsigned long int id[20];
string name[20];
float cost[20];
int quantity[20];
int z;
public:
void add_(void)/*add item to an inventory*/
{
cout<<" Enter the Item ID:";
cin>>id[z];
cout<<" Enter the Item Name:";
cin>>name[z];
cout<<" Enter the Price of the Item:";
cin>>cost[z];
cout<<" Enter The Item Quantity:";
cin>>quantity[z];
z++;/*to increase array pointer*/
}
void remove_(void)/*to remove from ID search and delete*/
{
int i,j,k,flag=0;
cout<<" Please Enter the Item ID:";
cin>>i;
for(j=0;j<z;j++)
{
if(id[j]==i)
{
flag=1;
for(k=j;k<z-1;k++)
{
id[k]=id[k+1];
name[k]=name[k+1];
cost[k]=cost[k+1];
quantity[k]=quantity[k+1];
}
}
}
if(flag==1)
{
z=z-1;
cout<<" The item is deleted from the list.";
}
else
{
cout<<" Item Not Present";
}
}
void display_(void)/*iterate z for displaying the list*/
{
int i;
if(z==0)
{
cout<<" No Items In Inventory";
}
for(i=0;i<z;i++)
{
cout<<" Item ID is :"<<id[i];
cout<<" Item Name is :"<<name[i];
cout<<" Item Price is :"<<cost[i];
cout<<" Item Quantity is:"<<quantity[i]<<" ";
}
}
void findbyid()/*take input id from user show the data*/
{
int i,j,flag=0;
cout<<" Please Enter the Item ID:";
cin>>i;
if(z==0)
{
cout<<" No Items to Display.";
}
for(j=0;j<z;j++)
{
if(id[j]==i)
{
cout<<" Item ID is :"<<id[j];
cout<<" Item Name is :"<<name[j];
cout<<" Item Price is :"<<cost[j];
cout<<" Item Quantity is:"<<quantity[j];
flag=1;
break;
}
}
if(flag==0)
{
cout<<" Item Not Found in Inventory";
}
}
void findbyname()/*take input item name and display it*/
{
string strname;
int i,flag=0;
cout<<" Please Enter the Item Name:";
cin>>strname;
for(i=0;i<z;i++)
{
if(name[i]==strname)
{
cout<<" Item ID is :"<<id[i];
cout<<" Item Name is :"<<name[i];
cout<<" Item Price is :"<<cost[i];
cout<<" Item Quantity is:"<<quantity[i];
flag=1;
break;
}
}
if(flag==0)
{
cout<<" Item Not Found in Inventory";
}
}
void initial(void){z=0;}/*initially z is equal to zero*/
};
int main ()
{
int i;
item shoping_mall;
shoping_mall.initial();
while(1)
{
cout<<" Inventory Management System"<<endl;
cout<<" 1: Add a new item.";
cout<<" 2: Remove an item.";
cout<<" 3: Print Item list.";
cout<<" 4: Find Item by ID.";
cout<<" 5: Find Item by Name.";
cout<<" 6: Exit Enter Your Choice:";
cin>>i;
switch(i)
{
case 1:
{
shoping_mall.add_();
break;
}
case 2:
{
shoping_mall.remove_();
break;
}
case 3:
{
shoping_mall.display_();
break;
}
case 4:
{
shoping_mall.findbyid();
break;
}
case 5:
{
shoping_mall.findbyname();
break;
}
case 6:
{
cout<<"Good Bye! Thank you.";
break;
}
}
if (i==6)
break;
}
return 0;
}
/*********************OUTPUT***********************
Inventory Management System
1: Add a new item.
2: Remove an item.
3: Print Item list.
4: Find Item by ID.
5: Find Item by Name.
6: Exit
Enter Your Choice:1
Enter the Item ID:1
Enter the Item Name:Mobile
Enter the Price of the Item:10000
Enter The Item Quantity:10
Inventory Management System
1: Add a new item.
2: Remove an item.
3: Print Item list.
4: Find Item by ID.
5: Find Item by Name.
6: Exit
Enter Your Choice:1
Enter the Item ID:2
Enter the Item Name:headphone
Enter the Price of the Item:1000
Enter The Item Quantity:10
Inventory Management System
1: Add a new item.
2: Remove an item.
3: Print Item list.
4: Find Item by ID.
5: Find Item by Name.
6: Exit
Enter Your Choice:1
Enter the Item ID:3
Enter the Item Name:bag
Enter the Price of the Item:500
Enter The Item Quantity:5
Inventory Management System
1: Add a new item.
2: Remove an item.
3: Print Item list.
4: Find Item by ID.
5: Find Item by Name.
6: Exit
Enter Your Choice:3
Item ID is :1
Item Name is :Mobile
Item Price is :10000
Item Quantity is:10
Item ID is :2
Item Name is :headphone
Item Price is :1000
Item Quantity is:10
Item ID is :3
Item Name is :bag
Item Price is :500
Item Quantity is:5
Inventory Management System
1: Add a new item.
2: Remove an item.
3: Print Item list.
4: Find Item by ID.
5: Find Item by Name.
6: Exit
Enter Your Choice:4
Please Enter the Item ID:3
Item ID is :3
Item Name is :bag
Item Price is :500
Item Quantity is:5
Inventory Management System
1: Add a new item.
2: Remove an item.
3: Print Item list.
4: Find Item by ID.
5: Find Item by Name.
6: Exit
Enter Your Choice:5
Please Enter the Item Name:Mobile
Item ID is :1
Item Name is :Mobile
Item Price is :10000
Item Quantity is:10
Inventory Management System
1: Add a new item.
2: Remove an item.
3: Print Item list.
4: Find Item by ID.
5: Find Item by Name.
6: Exit
Enter Your Choice:2
Please enter the Item ID:3
The item is deleted from the list.
Inventory Management System
1: Add a new item.
2: Remove an item.
3: Print Item list.
4: Find Item by ID.
5: Find Item by Name.
6: Exit
Enter Your Choice:3
Item ID is :1
Item Name is :Mobile
Item Price is :10000
Item Quantity is:10
Item ID is :2
Item Name is :headphone
Item Price is :1000
Item Quantity is:10
Inventory Management System
1: Add a new item.
2: Remove an item.
3: Print Item list.
4: Find Item by ID.
5: Find Item by Name.
6: Exit
Enter Your Choice:6
Good Bye! Thank you.
--------------------------------
Process exited after 138.3 seconds with return value 0
Press any key to continue . . .
**************************************************************/
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.