You must Sign In to post a response.
  • Category: Programming

    Program to prepare shopping list using array of objects.


    Are you preparing for BCA Object Oriented Programming using C_++ exams? Looking out for program code and explanation for preparing a shopping list using a array of objects? Here, on this Ask Expert page you can check out the solutions provided by experts.

    Following is a question that was asked in the question paper of BCA(Nov/Dec 2017 Bangalore University ) for subject Object Oriented Programming using C++(SN-659).

    This question is asked for 5 marks and hence requires some explanation along with the program code. Please let me know the solution -
    Q) Write a Program to prepare shopping list using array of objects. [ 5 Marks]
  • Answers

    2 Answers found.
  • You can refer the following webpage which is giving a beautiful explanation regarding making a programme for this.
    It is a tutorial with the heading 'Shopping List Application: Introducing Pointers, References and Dynamic Data Structures.
    http://web.csulb.edu/~hill/et286/Week%2012%20-%20Pointers%20and%20More%20About%20Classes.pdf
    This tutorial is giving an explanation with good references and examples.

    drrao
    always confident

  • Class is a user defined data type but it behaves like but in data type. So that it is possible to create array of objects of a class. This concept is used in the below program.
    Please include iostream.h, conio.h and stdio.h files before class declaration.
    //PROGRAM TO PREPARE SHOPPING LIST USING ARRAY OF OBJECTS
    #include
    #include
    #include
    class shop
    {
    private:
    char pname[20];
    int qty;
    float unitprice,bill;
    public:
    void input(void)
    {
    fflush(stdin);
    cout<<"\nEnter product name\n";
    gets(pname);
    cout<<"\nEnter product quentity\n";
    cin>>qty;
    cout<<"\nEnter per unit price of product\n";
    cin>>unitprice;
    bill=qty*unitprice;
    }
    void display(void)
    {
    cout<<"\nProduct name is "< cout<<"\nQuentity purchased is "< cout<<"\nUnit price of "< cout<<"\nTotal bill is "< cout<<"\n************************************************\n";
    }
    };
    void main(void)
    {
    class shop s1,s2,s3;
    clrscr();
    cout<<"\nEnter details for first user\n";
    s1.input();
    cout<<"\nEnter details for second user\n";
    s2.input();
    cout<<"\nEnter details for third user\n";
    s3.input();
    clrscr();
    cout<<"\nDetails of shopping list is as below\n";
    s1.display();
    s2.display();
    s3.display();
    getch();
    }


  • Sign In to post your comments