home *** CD-ROM | disk | FTP | other *** search
/ DP Tool Club 24 / CD_ASCQ_24_0995.iso / vrac / fahrcels.zip / FAHRCELS.CPP next >
C/C++ Source or Header  |  1995-04-01  |  875b  |  41 lines

  1. /****************
  2.  * fahrcels.cpp *
  3.  **********************************
  4.  * Converts Celsius to Fahrenheit *
  5.  * and vice versa                 *
  6.  **********************************/
  7.  
  8. #define LEVEL3
  9. #include "fuhf.h"
  10.  
  11. int main(void)
  12. {
  13.     clrscr();
  14.     cout <<
  15.     "Why, hello, there! I'm a handy little Celsius to Fehrentheit converter!"
  16.          << endl;
  17.     cout << "Would you prefer (C) to F or (F) to C? ";
  18.     char operation;
  19.     cin  >> operation;
  20.     operation = tolower(operation);
  21.     if(operation != 'c' && operation != 'f')
  22.     { cout << "Oops! Try again with C or F!"; exit(1); }
  23.     cout << "Okay, now the number to convert from: ";
  24.     float number;
  25.     cin  >> number;
  26.     if(operation == 'c')
  27.     {
  28.         number /= 5;
  29.         number *= 9;
  30.         number += 32;
  31.     }
  32.     else
  33.     {
  34.         number -= 32;
  35.         number /= 9;
  36.         number *= 5;
  37.     }
  38.     cout << "And the answer is: " << number << "!";
  39.     return 0;
  40. }
  41.