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

Answer the questions about the Temperature class definition shown below: 1. Whic

ID: 3695674 • Letter: A

Question

Answer the questions about the Temperature class definition shown below:

1.         Which function is known as the constructor?

a.         Temperature                                                                                        b.         setTemp

c.         getTemp d.         operator==

2.         Which function is known as a modifier function?

a.         Temperature                                                                                        b.         setTemp

c.         getTemp d.         operator==

3.         The user attempts the following code but it does not compile. Explain the problem.

Temperature winter;

winter.temp = 16.5;

__________________________________________________________________________

4.         Write the code to assign the temperature 37 ° C to a Temperature object named day.

__________________________________________________________________________

5.         What statement is true about the private data of object day after the user code below?

Temperature day;

a.         Data member temp stores 0

b.         Data member temp contains an undefined value.

c.         Data member temp stores whatever value the user specifies

6.         Write the code to display to the screen the Fahrenheit temperature stored in a Temperature object named day.

__________________________________________________________________________

                       

7.         Which user code correctly compares Temperature objects named one and two. If they are the same display word “OK”.

a.         if (one.getTemp( ) == two.getTemp( ) ) cout << “OK”;

b.         if (one == two) cout “OK”;

c.         if (one.temp == two.temp) cout << “OK”;

d.         Both choices a) and b) are correct.

e.         All choices a), b), and c) are correct.

8.         In most classes the data is stored in the _______________ section and the functions are stored in the ________________ section within the class definition.

a.         public, private

b.         private, public

c.         header, source code

d.         specification, implementation

9.         Assume class Temperature is divided into files Temperature.h and Temperature.cpp files. An application is written that needs to use a Temperature object. Which statement should be included at the top of the program?

a.         #include <Temperature>

b.         #include “Temperature.h”

c.         #include “Temperature.cpp”

d.         #include <Temperature.h>

10.       Which declaration causes the constructor function to be executed?

a.         Temperature daily;

b.         Temperature today ( );

c.         Temperature monday = 0;

d.         Temperature winter = Temperature ( );

class Temperature f public f POST: object has 0° C Temperature ); void setTemp (double value); POST: set the Celsius temperature double getTemp; double convert ); bool operator = (Temperature other); POST: return the Celsius temperature POST: return the Fahrenheit equivalent POST: return true if object and other have the same temp private: double temp; I temperature stored in Celsius units

Explanation / Answer

1. (a. Temperature)

2. (b. setTemp)

3. (because member variable "temp" is a private data member of the class. That's why we can't access it using dot notation. Hence the reason for the compilation error.)

4.

Temperature day;

day.setTemp(37);

5. (a. Data member temp stores 0)

6. cout << day.getTemp() << endl;

7. (d. Both choices a) and b) are correct.)(if it is cout << "ok"; in b instead of cout "ok"; otherwise "a" is the answer)

8. (b. private, public)

9. (b. #include “Temperature.h”)

10. a and d

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote