Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Design an Inventory class that can hold information for an item in a retail stor

ID: 3539121 • Letter: D

Question

Design an Inventory class that can hold information for an item in a retail store%u2019s inventory.


The class should have the following private member variables:

Variable Name   Description
itemNumber   An int that holds the item%u2019s number.
quantity               An int that holds the quantity of the item on hand.
cost    A double that holds the wholesale per-unit cost of the item



The class should have the following public member functions:


Member Function               Description
default constructor             Sets all the member variables to 0.

constructor #2                    Accepts an item%u2019s number, quantity, and cost as arguments. Calls other class functions to                                              copy these values into the appropriate member variables. Then calls the setTotalCost                                                 function.

setItemNumber      Accepts an int argument and copies it into the itemNumber member variable.
setQuantity             Accepts an int argument and copies it into the quantity member variable.
setCost   Accepts a double argument and copies it into the cost member variable.
getItemNumber     Returns the value in itemNumber.
getQuantity             Returns the value in quantity.
getCost                 Returns the value in cost.
getTotalCost   Computes and returns the totalCost.

Demonstrate the class by writing a simple program that uses it. This program should validate the user inputs to ensure that negative values are not accepted for item number, quantity, or cost.

Explanation / Answer

#include<iostream>


using namespace std;



class Inventory


{

public:

int itemNumber,Quantity;


double Cost,total;


  


Inventory()


{


itemNumber=0;


Quantity=0;


Cost=0;


}


Inventory(int number,int quantity,double cost)


{


  


setItemNumber(number);


setQuantity(Quantity);


setCost(Cost);


  


}


void setItemNumber(int number)


{


itemNumber=number;


}


void setQuantity(int quantity)


{


Quantity=quantity;


}


void setCost(double cost)


{


Cost=cost;


}


int getItemNumber()


{


return itemNumber;


}


int getQuantity()


{


return Quantity;


}


double getCost()


{


return Cost;


}


double getTotal()


{


total=(double)Cost*Quantity;


return total;


}


};

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote