Friday 16 December 2016

c++ program to make a heater with lowest and highest temperatures using a class and objects.



#include <iostream>                                  
using namespace std;
class heater
{
private:
    int temp;
    int mini;
    int maxi;
    int incre;
public:
    heater()
    {  temp=15;}
    heater (int z )
    {  incre=z;}
    heater(int x, int y): mini(x),maxi(y)
    { }
    void warmer()
    {
        temp=temp+incre;
        if(temp>maxi)
            cout<<"warmest temperature"<<temp<<endl;
        else
            cout<<"temperature is high";
    }
    void cold()
    {
        temp=temp-incre;
        cout<<"temperature is cold"<<temp;
  }
    int output()
    {
        cout<<temp<<endl;
        return temp;
    }
};
int main()
{
 heater obj2(5);
    heater obj3(0,30);
heater temp;
    temp.warmer();
    temp.cold();
    temp.output();
retorn 0;
}

No comments:

Post a Comment