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

class bagType { public: void set(string, double, double, double, double); void p

ID: 3676562 • Letter: C

Question

class bagType

{

public:

void set(string, double, double, double, double);

void print() const;

string getStyle() const;

double getPrice() const;

void get(double, double, double, double);

bagType();

bagType(string, double, double, double, double);

private:

string style;

double l;

double w;

double h;

double price;

};

bagType    newBag;          //variable declaration

a. Write the definition of the member function set so that private members are set according to the parameters.

b. Write the definition of the member function print that prints the values of the data members.

c. Write the definition of the default constructor of the class bagType so that the private member variables are initialized to "", 0.0, 0.0, 0.0, 0.0, respectively.

d. Write a C++ statement that prints the value of the object newBag.

e. Write a C++ statement that declares the object tempBag of type bagType, and initializes the member variables of tempBag to "backPack", 15, 8, 20, and 49.99, respectively.

f. Write a C++ statement using operator (<<) that prints the value of the object newBag.

g. Write a C++ statement using operator (>>) that reads the value of the object newBag.

Consider the following declarations: (1, 2, 5, 7) class bagType public: 6. void set (string, double, double, double, double) void print) const; string getStyle () const; double getPrice () const; void get (double, double, double, double); bagType (); bagType (string, double, double, double, double) private: string style; double l; double w; double h; double price; bagType newBag //variable declaration a. Write the definition of the member function set so that private b. Write the definition of the member function print that prints the c. Write the definition of the default constructor of the class bagType so members are set according to the parameters values of the data members. that the private member variables are initialized to "", 0.0,0.0,0.0 0.0, respectively d. Write a C++ statement that prints the value of the object newBag. e. Write a C++ statement that declares the object tempBag of type bagType, and initializes the member variables of tempBag to "backPack", 15, 8, 20, and 49.99, respectively.

Explanation / Answer

class bagType
{
public:
void set(string, double, double, double, double);
void print() const;
string getStyle() const;
double getPrice() const;
void get(double, double, double, double);

//c
bagType();
{
;
l = 0.0;
w = 0.0;
h = 0.0;
price = 0.0;
}

bagType(string = " bag", double = 22.0, double = 45.022, double = 5.3, double = 421.33);

private:
   string style;
   double l;
   double w;
   double h;
   double price;
};

//a
void bagType::set(string = "travel bag", double = 55.0, double = 45.2, double = 25.00, double = 455.20){
cout << style <<'-' << l << '-' << w << '-' << h << '-' << price;
}

//b
bagType::bagType(string s, double length, double width, double height, double p){
style = s;
l = lenght;
w = width;
h = height;
price = p;
}


void bagType::print(){
cout<< l << '-' << w << '-' << h << '-' << price:
}

int main()
{
newBag.set();
newBag.getStyle("college bag");
newBag.getPrice(15.22);
newBag.get(45, 54.00, 541.20);

// d
newBag.print();

// e
bagType tempBag("backPack", 15, 8, 20, 49.99), newBag;

// g
cin >> style >> l >> w >> h >> price;
newBag.print();

// f
cout<<" newBag value =";
newBag.print();
return 0;
}