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;
}
};
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.