Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Computer Performance Engineering 10th European Workshop Epew 2013 Venice Italy September 17 2013 Proceedings

Authors: Maria Simonetta Balsamo ,William Knottenbelt ,Andrea Marin

2013 Edition

3642407242, 978-3642407246

More Books

Students also viewed these Programming questions

Question

What is a reporting entity?

Answered: 1 week ago

Question

3 When might constructivist view of self be not relevant and why?

Answered: 1 week ago