// temperature100.cpp  02/27/2002  cis205 C/C++ Programming

// converts temperatures from/to Celsius, Kelvin, and Fahrenheit

// version 1.00
// demonstrates passing parameters to functions by value
// and returning values from functions


// Expectation values: 
//   0.00 K = -273.15 °C = -459.67 °F  // absolute zero
// 273.15 K =    0.00 °C =   32.00 °F  // freezing point of water
// 373.15 K =  100.00 °C =  212.00 °F  // boiling point of water

// Daniel Fahrenheit (1686-1736) http://www.gi.alaska.edu/ScienceForum/ASF13/1317.html
// Anders Celsius    (1701-1744) http://www.astro.uu.se/history/Celsius_eng.html
// William Kelvin    (1824-1907) http://www.infoplease.com/ce6/people/A0827333.html

/*
	Sample Output

C:\cis205\2002\spring\examples>temperature100.exe
-459.67

*/
// pre-processor directive
#include 

// prototypes (function skeletons)
void convertCtoK(float);  // function accepts a float, returns nothing
void convertKtoC(float);
void convertCtoF(float);
void convertFtoC(float);
void convertKtoF(float);
void convertFtoK(float);
void explain(void);

int main(void)
{

	int intConversionType = 3;  // celsius to fahrenheit
	float fltTemperature = -273.15;  // celsius, expect fahrenheit -459.5=67
	float fltResult;

	switch(intConversionType)
	{
		case 1: // celsius to kelvin
			convertCtoK(fltTemperature);
			break;
		case 2: // kelvin to celsius
			convertKtoC(fltTemperature);			
			break;
		case 3: // celsius to fahrenheit
			convertCtoF(fltTemperature);			
			break;
		case 4: // fahrenheit to celsius
			convertFtoC(fltTemperature);
			break;
		case 5: // kelvin to fahrenheit
			convertKtoF(fltTemperature);
			break;
		case 6: // fahrenheit to kelvin
			convertFtoK(fltTemperature);
			break;
		default:
			explain();
			break;
	}

	return 0;

}

void convertCtoK(float fltTC)  // case 1
{
	float fltResult;

	fltResult = fltTC + 273.15f;

	cout << fltResult << endl;
}


void convertKtoC(float fltTK)  // case 2
{
	float fltResult;

	fltResult = fltTK - 273.15f;

	cout << fltResult << endl;
}

void convertCtoF(float fltTC)  // case 3
{
	float fltResult;

	fltResult = (fltTC * (9.00f / 5.00f)) + 32.00f;

	cout << fltResult << endl;
}

void convertFtoC(float fltTF)  // case 4
{
	float fltResult;

	fltResult = (fltTF - 32.00f) * (5.00f / 9.00f);

	cout << fltResult << endl;
}

void convertKtoF(float fltTK)  // case 5
{
	float fltResult;
	float fltHold;

	// in two steps:
	fltHold = fltTK - 273.15f;  // kelvin to celsius
	fltResult = (fltHold * (9.00f / 5.00f)) + 32.00f; // celsius to fahrenheit

	cout << fltResult << endl;
}


void convertFtoK(float fltTF)  // case 6
{
	float fltResult;
	float fltHold;

	// in two steps:
	fltHold = (fltTF - 32.00f) * (5.00f / 9.00f);  // fahrenheit to celsius
	fltResult = fltHold + 273.15f; // celsius to kelvin

	cout << fltResult << endl;
}

void explain(void)  // default case
{
	cout << "Specify a conversion type (1..6) and temperature" << endl;
}