TempConversion.cpp and exe

Apr 29, 2005 14:29


Ok, I finished my code finally and I compiled it. It works just fine. You can download the program at  http://www.17clowns.com/cpp/TempConversion.exe   Here is the code:

    // Temperature Conversion Tool
    //
    // This is just a simple program I am making in the process of learning C++
    // Keep your eyes opened, because I hope to move on to network tools soon.
    //
    // c=(f-32)/9*5;
    // f=c*9/5+32;
    //
    // Program by «ºHîñd§îgh†º»
    //////////////////////////////////////////////////////////////////////////////////////
    #include
    #include
    using namespace std;
    int main(void)
    {
       char
         x='f',y='y';

    cout << "Would you like to convert from (F)arenheit or (C)elcius? ";
         cin >> x;
     while (y=='y'||y=='Y')
       {
        if (x=='f'||x=='F')
        {
          float f=0.00;
          cout << "Enter a temperature to be converted from Farenheit to Celcius. ";
          cin >> f;
          float c=(f-32.00)/9.00*5.00;
          cout << c <<" degrees Celcius is equal to "<< f <<" degrees Farenheit.\n\n"<    }
        else if (x=='c'||x=='C')
        {
          float c=0.00;
          cout << "Enter a temperature to be converted from Celcius to Farenheit. ";
          cin >> c;
          float f=c*9.00/5.00+32.00;
          cout << f <<" degrees Farenheit is equal to "<< c <<" degrees Celcius.\n\n"<    }
         cout << "Would you like to convert from (F)arenheit or (C)elcius? ";
         cin >> x;
       }
      return 0;
    }

I'm sure there are alot of other ways to do it, but mine works. If you know of any ways that are better than mine, let me know.

Thanks, Hindsight
Previous post Next post
Up