Hi am making a project in c++. i need to make an inventory of shopping mart, i just need to make a search option where i can search according to my preference i.e. type, price, purchase date etc.
how do i declare my inventory for example if i want chocolates how do i declare the brand, price, quantity, etc. PLEASE HELP
#include <iostream>
#include <string>
usingnamespace std;
void Inventory(){
string name []
string brand;
string string;
int qty;
double price;
}
int main()
{
int choice, search;
cout<<"\t\t\tWhat would you like to do?\n\nPress 1 to Search Inventory.\nPress 2 to Add Items.\n";
cin>>choice;
if (choice == 1)
cout<<"\n\nPress 1 to search by Type.\nPress 2 to search by Price.\nPress 3 to search by Purchase date.";
switch (search)
case 1:
return 0;
}
you probably want a container of user defined objects, eg
class item
{
string name;
string brand;
// string string; // don't ever do this! even if you get it working, please, don't do this to your readers or yourself.
int qty;
int price; //doubles and money are a no-no. just put price in cents (assuming $USA type currency?). you may find that when you put in something like $19.99 you really got 19.98999999999999 or something obnoxious if you used doubles.
...etc;
};
vector<item> inventory; //now you can add all the stuff here and search it as you see fit etc.