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

x.Hmve a program that I wanna add a class to, and make it inherit the class that

ID: 3618426 • Letter: X

Question

x.Hmve a program that I wanna add a class to, and make it inherit the class that's within the program. In this thermostat code I want to, simply modify it, to use inheritance to create aclass that will also keep track of whether the thermostat is turned on.   you could then add a particular default forthis value, add two menu options for turning it on and turning it off, anddefine a new function to display the status of the thermostat including thetemperature, the mode, and this new value.

The code is as shown below


#include <iostream>

using namespace std;


class Thermostat
{
      private:
              int temp;
              char mode;
      public:
             Thermostat()// set the thermostat to 70.
             {
                 temp = 70;
                 mode = 'f';
             }
             void DecreaseTempByOne()//decrease the thermostat by one each time"
             {
                  temp = temp -1;
                  cout<<" Temperature Decrease by 1";
              }
             void IncreaseTempByOne()//increase the thermostat by one each timeI
             {
                  temp = temp + 1;
                  cout<<" Temperature Increase by 1";
              }
             void ChangeTemp(int t)// notify the user that the thermostat was c.
             {
                  temp = t;
                  cout<<" Temperature Changed Succesfully";
             }

             void SetModeToCelsius()//change to Celsius.
             {
                  if(mode == 'c')
                     cout<<" Mode is already on Celsius";
                  else
                  {
                      temp= (temp-32) * 5/9;// using the conversion formula fro.
                      mode = 'c';
                      cout<<" Mode Set to Celsius";
                  }
              }

              void SetModeToFahrenheit()//change to Fahrenheit.
             {
                   if(mode != 'f')
                   {
                       temp= (temp *9/5) + 32;//using the conversion formula fr.
                       mode = 'f';
                       cout<<" Mode Set to Fahrenheit";
                   }else
                       cout<<" Mode is already on Fahrenheit";
              }

             void showTempAndMode()//display the function status.
             {
                  if(mode == 'c')
                  {
                       cout<<"Temperature Mode : Celsius ";
                       cout<<"Temperature      :"<<temp<<" C ";
                   }
                   if(mode == 'f')
                  {
                       cout<<"Temperature Mode : Fahrenheit ";
                       cout<<"Temperature      :"<<temp<<" F ";;
                   }
             }
};

int main()
{
  &

Explanation / Answer

x.H #include #include /** I have a program that I wanna add a class to, and make it inherit the class that's within the program. In this thermostat code I want to , simply modify it, to use inheritance to create a class that will also keep track of whether the thermostat is turned on.   you could then add a particular default for this value, add two menu options for turning it on and turning it off, and define a new function to display the status of the thermostat including the temperature, the mode, and this new value. */ class Thermostat {       private:               int temp;               char mode;       public:              Thermostat()// set the thermostat to 70.              {                  temp = 70;                  mode = 'f';              }            int getTemp()            {                return temp;            }            char getMode()            {                return mode;            }              void DecreaseTempByOne()//decrease the thermostat by one each time"              {                   temp = temp -1;                   cout