Thread: sorry to bother all but please help me :)

  1. #1
    Registered User
    Join Date
    Feb 2005
    Posts
    4

    help w/ farenheit to celcius converter prog please :)

    i have been trying to make a farenheit to celcius converter for about to days ( ya sorry its a big task for me i have only been coding for a day)
    and i can get the loop and evrything to work but for some reason i cannot get the far temp to conv. to celcius . Say i was to enter 100 degrees far. i would get a 68 degrees cel. its like it is not reading the 5/9 before the far-32 any help would be appr. and here is my code

    [code]

    // Farenhiet to Celcius converter
    #include <iostream>
    using namespace std;

    int main()
    {
    int a;
    int b = 1;
    do {
    float far;
    cout<<"Please enter youre farenheit amount to be converted to Celcius: ";
    cin>>far;
    cin.ignore();
    float cel;
    cel = (5/9)*(far-32);
    cout<< far <<" degrees farneheit is: " << cel << " In Celcius\n";

    cout<<"do you want to repeat?( 1 is no any other number is yes) ";
    cin>>a;
    cin.ignore();
    }while ( a != b );
    cin.get();
    }
    Last edited by cam123666; 02-04-2005 at 03:55 PM.

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,659
    Nice attempt at code tags - shame you didn't review the post as well, then you'd see it was still a mess.

    > 5 / 9
    Is always 0 in C++
    If you want a floating point division, then try 5.0 / 9.0
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  3. #3
    Registered User
    Join Date
    Feb 2005
    Posts
    4
    ok sorry
    <---- admits he was an idiot for not reading the (before you post code read here)

    but ne ways i still try it and i get a 8.12753e-044 on everything i try to enter
    Is there something wrong with the formula i am using or what ? I do not understand why it is doing this and anyhelp will be appreciated


    oops sorry i made a simple coding mistake ty for the help it works now
    sorry to bother
    Last edited by cam123666; 02-04-2005 at 04:12 PM.

  4. #4
    Registered User
    Join Date
    Feb 2005
    Posts
    44
    Code:
    #include <iostream>
    using namespace std;
    
    int main()
    {
    int a;
    int b = 1;
    do {
    float far = 0.0F;
    cout<<"Please enter youre farenheit amount to be converted to Celcius: ";
    cin>>far;
    cin.ignore();
    float cel = 0.0F;
    cel = (5.0 / 9.0)*(far-32);
    cout<< far <<" degrees farneheit is: " << cel << " In Celcius\n";
    
    cout<<"do you want to repeat?( 1 is no any other number is yes) ";
    cin>>a;
    cin.ignore();
    }while ( a != b );
    cin.get();
    }
    That should work
    Last edited by Kaelin; 02-04-2005 at 04:25 PM.

  5. #5
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    Quote Originally Posted by Salem
    Nice attempt at code tags - shame you didn't review the post as well, then you'd see it was still a mess.

    > 5 / 9
    Is always 0 in C++
    *tries resisting* I can'... it's too much...

    Are you sure about that?

    Bwhahah.

    Heh... well technically, that's in C so...

    Quzah.
    Hope is the first step on the road to disappointment.

  6. #6
    People Love Me
    Join Date
    Jan 2003
    Posts
    412
    Quote Originally Posted by quzah
    *tries resisting* I can'... it's too much...

    Are you sure about that?

    Bwhahah.

    Heh... well technically, that's in C so...

    Quzah.
    ...Wow, that master5001 guy sure did get his panties in a bunch over something stupid.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Reading Excel Row Cells A through J
    By CheyenneWay in forum C++ Programming
    Replies: 37
    Last Post: 03-17-2011, 08:00 AM
  2. Should I bother with these?
    By incognito in forum Windows Programming
    Replies: 3
    Last Post: 01-03-2004, 11:31 PM
  3. Questions for IT professionals.......(yeah I know I bother too much...)
    By incognito in forum A Brief History of Cprogramming.com
    Replies: 2
    Last Post: 11-14-2003, 07:08 PM
  4. Ok. sorry to bother you guys with a newb question.
    By arnis in forum C++ Programming
    Replies: 12
    Last Post: 07-17-2003, 11:23 AM
  5. Do bees bother you?
    By Shadow in forum A Brief History of Cprogramming.com
    Replies: 32
    Last Post: 03-23-2003, 09:42 PM