menu search
brightness_auto
more_vert
Write an Object Oriented Program in C++, to implement inventory class to calculate total price of number of items purchased.
thumb_up_off_alt 0 like thumb_down_off_alt 0 dislike

1 Answer

more_vert
 
verified
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::


thumb_up_off_alt 0 like thumb_down_off_alt 0 dislike

Related questions

thumb_up_off_alt 0 like thumb_down_off_alt 0 dislike
1 answer
thumb_up_off_alt 0 like thumb_down_off_alt 0 dislike
1 answer
thumb_up_off_alt 0 like thumb_down_off_alt 0 dislike
1 answer
thumb_up_off_alt 1 like thumb_down_off_alt 0 dislike
1 answer
thumb_up_off_alt 0 like thumb_down_off_alt 0 dislike
1 answer
thumb_up_off_alt 0 like thumb_down_off_alt 0 dislike
1 answer

Doubtly is an online community for engineering students, offering:

  • Free viva questions PDFs
  • Previous year question papers (PYQs)
  • Academic doubt solutions
  • Expert-guided solutions

Get the pro version for free by logging in!

5.7k questions

5.1k answers

108 comments

648 users

...