pls help me. i have got a school project to make a program that generates a shopping bill and shows the present stock at end of bill.
also
1.the user inputs only the quantity and product code(thats where i am facing problem to feed the product codes in my program and then link them with product names)
2.also i want some special offers to be given to customers(but first i will complete step one and then go for the second)

this is my program which is presently incomplete and wrong too:

#include<conio.h>
#include<iostream.h>
class product
{public:
int code,amnt;
float rate,price;
price=rate*amnt;
char name[10];
};
class stock:public product
{public:
};
main()
{int i=1;
float bill=0;
    product.shop[15];
    stock.mystock[15];

    char c='y';
    while(c=='y')
    {bill=0;
        cout<<"WELCOME TO CHITKARA SUPERMART :\nThe present stock is: \n";

        for(i=1;i<=15;i++)
        {cout<<"enter product code:";
        cin>>shop[i].code;
        cout<<" enter quantity: ";
        cin>>shop[i].amnt;
        switch(shop[i].code)
        {case 1: shop[i].name="lays";
        mystock[i].amnt--;
        mystock[i].name= "lays";
        shop[i].price=20;
        break;
        case 2: shop[i].name="soap";
        mystock[i].amnt--;
        mystock[i].name= "soap";
        shop[i].price=40;
        }
        }
        cout<<"your bill is:\nproduct\tamount\trate\tprice\n"<<shop[i].name<<"\n"<<shop[i].name<<"\t"<<shop[i].amnt<<"\t"<<shop[i].price;


        }
cout<<"\"THANK YOU !\" PLEASE VISIT AGAIN !";


getch();    
}

First thing is that you need a list of the items for sell and quantities on hand. You might have something like this:

class item
{
   std::string name;
   std::string upc_number; // prodct it, or barcode
   int quantity;
   float price;
};

Now create a vector of those for each item you want to sell.

Next you need another list if items that the customer is buying. The only things it needs are upc and quantity. When you print the customer's bill you can find product name and price by looking up the upc in the vector of products for sell.

First thing is that you need a list of the items for sell and quantities on hand. You might have something like this:

class item
{
   std::string name;
   std::string upc_number; // prodct it, or barcode
   int quantity;
   float price;
};

Now create a vector of those for each item you want to sell.

Next you need another list if items that the customer is buying. The only things it needs are upc and quantity. When you print the customer's bill you can find product name and price by looking up the upc in the vector of products for sell.

thanks for helping but i am unable to understand what u meant as i am just a begginer pls help in detail...

Vectors in C++

Vectors can not only contain numbers but also objects - like the items of your store. Each entry then in the vector is/points at (depending on the implementation) an object of the type item with its associated member variables/functions.

#include "item.h"
#include <vector>

int main() {
   std::vector<item*> my_item_list;

return 0;
}

You could work now with my_item_list.

Since this is a school project, and very obviously you haven't learned vectors, make an array of your class product and you can fill each product with your data.

pls i already informed u that i really dont know how to use vectors and go about the program....

pls help /.....

also how will i show the stock...

Since this is a school project, and very obviously you haven't learned vectors, make an array of your class product and you can fill each product with your data.

pls help as then using array how will i assign codes to items ,also how will i show the stock....

It's obvious you skipped the entire chapter on using the variables in the class you defined. Try reading that chapter and looking at the code again.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.