Thread: Thermometer Class

  1. #16
    Reverse Engineer maxorator's Avatar
    Join Date
    Aug 2005
    Location
    Estonia
    Posts
    2,318
    But my code worked, it outputted 86 degrees Fahrenheit when you inputted 30 degrees Celsius.
    "The Internet treats censorship as damage and routes around it." - John Gilmore

  2. #17
    Is Trying to Learn
    Join Date
    Mar 2006
    Location
    Hutton, Preston
    Posts
    215
    yes i know it worked but i wanted to change it differently thats all.

  3. #18
    Reverse Engineer maxorator's Avatar
    Join Date
    Aug 2005
    Location
    Estonia
    Posts
    2,318
    Ah ok, I am not really good at making alternative equasions.
    "The Internet treats censorship as damage and routes around it." - John Gilmore

  4. #19
    Is Trying to Learn
    Join Date
    Mar 2006
    Location
    Hutton, Preston
    Posts
    215
    its ok, you think you can help with my new problem with the equation?

  5. #20
    Reverse Engineer maxorator's Avatar
    Join Date
    Aug 2005
    Location
    Estonia
    Posts
    2,318
    Not at the moment, it's bedtime
    "The Internet treats censorship as damage and routes around it." - John Gilmore

  6. #21
    Is Trying to Learn
    Join Date
    Mar 2006
    Location
    Hutton, Preston
    Posts
    215
    right ok, anyone else?

  7. #22
    MFC killed my cat! manutd's Avatar
    Join Date
    Sep 2006
    Location
    Boston, Massachusetts
    Posts
    870
    This:
    Code:
    mDegreesC = 9.0/5.0*(DegreesF-32.0);
    Should be this:
    Code:
    mDegreesC = 1.8*DegreesF+32.0;
    Silence is better than unmeaning words.
    - Pythagoras
    My blog

  8. #23
    Is Trying to Learn
    Join Date
    Mar 2006
    Location
    Hutton, Preston
    Posts
    215
    i would use that but i need to use the full formula which is the one that i have.

    i dont know if there is anything wrong with the GetDegreesF function when i return it?

    because when i put in the temperature it comes up with a weird number. and then whatever i put in for the next number it will come up as 57.6
    Last edited by peckitt99; 11-02-2006 at 04:30 PM.

  9. #24
    Is Trying to Learn
    Join Date
    Mar 2006
    Location
    Hutton, Preston
    Posts
    215
    still not managed to figure this one out. can anyone help?

  10. #25
    MFC killed my cat! manutd's Avatar
    Join Date
    Sep 2006
    Location
    Boston, Massachusetts
    Posts
    870
    Have you tried adding 32 not subtracting it?
    Silence is better than unmeaning words.
    - Pythagoras
    My blog

  11. #26
    The larch
    Join Date
    May 2006
    Posts
    3,573
    Quote Originally Posted by peckitt99
    i would use that but i need to use the full formula which is the one that i have.

    i dont know if there is anything wrong with the GetDegreesF function when i return it?

    because when i put in the temperature it comes up with a weird number. and then whatever i put in for the next number it will come up as 57.6
    Does it have anything to do with the conversion formulas, or that your code has some other problems. As you describe it, may-be you could show the code that is giving problems.

    Have you fixed the problem that the class should only store the temperature in one variable, to avoid the termometer storing two different temperatures at a time? I would suggest Kelvins for that (makes it easy to check you don't get below 0 K).

    It's easy to find conversion formulas on the Internet, for example here.

  12. #27
    Registered User
    Join Date
    Nov 2006
    Posts
    25
    isn't this a lot easier
    Code:
    #include<iostream.h>
    
    int main()
    {
    	int temp1;
    	double temp2, temp3;
    	char temp4;
    	cout<<"(1)Fahrenheit or (2)Celcius?"<<endl;
    	cin>>temp1;
    	cout<<"Degree?"<<endl;
    	cin>>temp2;
    	if(temp1==1)
    	{
    		temp3=((.056)*(temp2-32))*10;
    		temp4='C';
    	}
    	if(temp1==2)
    	{
    		temp3=(temp2)*(1.8)+32;
    		temp4='F';
    	}
    	cout<<temp3<<" deg "<<temp4<<endl;
    	
    	return 0;
    }

  13. #28
    Is Trying to Learn
    Join Date
    Mar 2006
    Location
    Hutton, Preston
    Posts
    215
    it has to be in a class

  14. #29
    Is Trying to Learn
    Join Date
    Mar 2006
    Location
    Hutton, Preston
    Posts
    215
    its ok thanx i got it. thanks for your help

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Class design problem
    By h3ro in forum C++ Programming
    Replies: 10
    Last Post: 12-19-2008, 09:10 AM
  2. Specializing class
    By Elysia in forum C++ Programming
    Replies: 6
    Last Post: 09-28-2008, 04:30 AM
  3. matrix class
    By shuo in forum C++ Programming
    Replies: 2
    Last Post: 07-13-2007, 01:03 AM
  4. Screwy Linker Error - VC2005
    By Tonto in forum C++ Programming
    Replies: 5
    Last Post: 06-19-2007, 02:39 PM