Question: In c++ Consider the following statements: class temporary { public: void set(string, double, double); void print(); double manipulate(); void get(string&, double&, double&); void setDescription(string); void

In c++

Consider the following statements:

class temporary
{
public:
void set(string, double, double);
void print();
double manipulate();
void get(string&, double&, double&);
void setDescription(string);
void setFirst(double);
void setSecond(double);
string getDescription() const;
double getFirst()const;
double getSecond()const;

temporary(string = "", double = 0.0, double = 0.0);

private:
string description;
double first;
double second;
};

Now answer the following questions:

Write the definition of the member function set so that theinstance variables are set according to the parameters.

Write the definition of the member function manipulate thatreturns a decimal number as follows: If the value of description is"rectangle", it returns first * second; if the value of descriptionis "circle", it returns the area of the circle with radius first;if the value of description is "sphere", it returns the volume ofthe sphere with radius first; if the value of description is"cylinder", it returns the volume of the cylinder with radius firstand height second; otherwise, it returns the value -1.

Write the definition of the function print to print the valuesof the instance variables and the values returned by the functionmanipulate. For example, if description = "rectangle", first= 8.5, and second = 5, it should print: rectangle: length= 8.50, width = 5.00, area = 42.50

Write the definition of the constructor so that it initializesthe instance variables using the function set.

Write the definition of the remaining functions to set orretrieve the values of the instance variables. Note that thefunction get returns the values of all instance variables.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!