Skip to content
doubtly

1 answer

Best answer

#include <iostream>

using namespace std;

 

class inventory

{

    private:

        int   no_of_items;

        float total_price;

        float price;

    public:

        void getData(void);

        void calculate(void);

        void putData(void);

};

 

void inventory::getData(void)

{

    cout << "Enter number of items to be purchased: "<<endl ;

    cin >> no_of_items;

    cout << "Enter Price of each items purchased ";

    cin >> price;

     

}


void inventory::calculate(void)

{

total_price=(float)no_of_items*price;

cout<<"Total price of number of Items Purchased are:"<<total_price;

}

 

void inventory::putData(void){

    cout << "Items Purchasing details:"<<endl;

    cout << "Number of Items purchased is:"<< no_of_items <<endl;

cout<<"Price Per items is:" <<price<<endl;

calculate();

}

 

int main()

{

    inventory in;

    in.getData();

    in.putData();

    return 0;

}


Output::

https://lh3.googleusercontent.com/-XUyUUQjEWtQ/YYkcfKJ1a2I/AAAAAAAACsk/yEMXXW640YQ3d08_Q4htBdQ3ItMhSVAGQCLcBGAsYHQ/image.png

Doubtly · 8 Nov 2021 Report
Was this answer helpful?

Your answer

Log in or create a free account to answer this question.