home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
DP Tool Club 24
/
CD_ASCQ_24_0995.iso
/
vrac
/
fahrcels.zip
/
FAHRCELS.CPP
next >
Wrap
C/C++ Source or Header
|
1995-04-01
|
875b
|
41 lines
/****************
* fahrcels.cpp *
**********************************
* Converts Celsius to Fahrenheit *
* and vice versa *
**********************************/
#define LEVEL3
#include "fuhf.h"
int main(void)
{
clrscr();
cout <<
"Why, hello, there! I'm a handy little Celsius to Fehrentheit converter!"
<< endl;
cout << "Would you prefer (C) to F or (F) to C? ";
char operation;
cin >> operation;
operation = tolower(operation);
if(operation != 'c' && operation != 'f')
{ cout << "Oops! Try again with C or F!"; exit(1); }
cout << "Okay, now the number to convert from: ";
float number;
cin >> number;
if(operation == 'c')
{
number /= 5;
number *= 9;
number += 32;
}
else
{
number -= 32;
number /= 9;
number *= 5;
}
cout << "And the answer is: " << number << "!";
return 0;
}