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

Consider the definition of the class productType as given in Exercise 8 Answer t

ID: 3585152 • Letter: C

Question

Consider the definition of the class productType as given in Exercise 8 Answer the following questions. (1, 2, 3, 5,7) Write the definition of the function set so that instance variables are set according to the paramaters. Instance variables quantitiesInstock, price, and discount must be nonnegative. Write the definition of the function print to output the values of the instance variables a. b. c. Write the definition of the function setQuantitiesInstock to set the value of the instance variable quantitiesInstock accord ing to the parameter.

Explanation / Answer

class productType {
private:
int quatityInStock;
double price;
double discount;
public:
productType() {
  
}
void set(int q, double p, double d) {
if(q >= 0) {
quatityInStock = q;
}
if(p >= 0 ){
price = p;
}
if(d >=0) {
discount = d;
}
}
void print() {
cout<<"Quatity in Stock: "<<quatityInStock<<" Price: "<<price<<" Discount: "<<discount<<endl;
}
void setQuatityInStock(int q) {
quatityInStock = q;
}
};