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: class T

ID: 3693048 • Letter: A

Question

Answer the questions about the Temperature class definition shown below:

class Temperature {

public:

Temperature ( );                                                  // POST: object has 0º C

void setTemp (double value);     // POST: set the Celsius temperature

double getTemp ( );                                             // POST: return the Celsius temperature

double convert ( );                                               // POST: return the Fahrenheit equivalent

bool operator == (Temperature other);

                                                                                                      // POST: return true if object and other have the same temp

private:

            double temp;                                                              // temperature stored in Celsius units

};

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

b.         #include “Temperature.h”

c.         #include “Temperature.cpp”

d.         #include

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

a.         Temperature daily;

b.         Temperature today ( );

c.         Temperature monday = 0;

d.         Temperature winter = Temperature ( );

Explanation / Answer

1. Answer is A

2.Answer is B

3.temp is a private member of the class. So it cannot be accessed using an object of the class.

4.Temperature day;

day.setTemp(37);

5.Answer A

6.void displayTemp(Temperature day)

{

court<<day.convert();

}

double convert()

{

return this.temp*1.8000+32.00;

}

7.answer is D

8.Answer is B

9.Answer is B

10.Answer is B

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