Here is an example of a C++ program. Programmed by iKent
-------------------------------------------------------------
-------------------------------------------------------------
- Code:
/*
For more C++ programs, visit www.cybermix.tk
Programmed by iKent
*/
#include <cstdlib>
#include <iostream>
#include <conio.h>
using namespace std;
int main()
{
char from,to;
float k,c,f;
cout<<"Temperature Converter By iKent" <<endl;
cout<<"Choose a temperature to be converted" <<endl;
cout<<"a. Celsius" <<endl;
cout<<"b. Fahrenheit" <<endl;
cout<<"c. Kelvin" <<endl;
cout<<"Choose: ";
cin>>from;
switch (from)
{ case 'a':
cout<<"\n\nCelsius to..." <<endl;
cout<<"a. Fahrenheit" <<endl;
cout<<"b. Kelvin" <<endl;
cout<<"Choose: ";
cin>>to;
if (to=='a')
{
cout<<"Input celsius: " <<endl;
cin>>c; f=(c*9/5)+32;
cout<<"The temperature of Celsius to Fahrenheit is: " <<f;
cout<<" F" <<endl;
}
if (to=='b')
{ cout<<"Input Degree Celsius: ";
cin>>c; k=c+273.15;
cout<<"The temperature of Celsius to Kelvin is: " <<k;
cout<<" K" <<endl;
}
break;
case 'b':
cout<<"Fahreheit to..." <<endl;
cout<<"a. Celsius" <<endl;
cout<<"b. Kelvin" <<endl;
cout<<"Choose: ";
cin>>to;
if (to=='a')
{
cout<<"Input Degree Fahrenheit: " <<endl;
cin>>f;
c=(f-32)*5/9;
cout<<"The temperature of Fahrenheit to Celsius is: " <<f;
cout<<" C" <<endl;
}
if (to=='b')
{
cout<<"Input Fahrenheit: ";
cin>>f;
k=(f+459.67)*5/9;
cout<<"The temperature of Fahrenheit to Kelvin is: " <<k;
cout<<" K" <<endl;
}
break;
case 'c':
cout<<"Kelvin to..." <<endl;
cout<<"a. Celsius" <<endl;
cout<<"b. Fahrenheit" <<endl;
cout<<"Choose: ";
cin>>to;
if (to=='a')
{
cout<<"Input Kelvin: " <<endl;
cin>>k;
c=k-273.15;
cout<<"The temperature of Kelvin to Celsius is: " <<c;
cout<<" C" <<endl;
}
if (to=='b')
{
cout<<"Input Kelvin: ";
cin>>k; f=(k*9/5)-459.67;
cout<<"The temperature of Kelvin to Fahrenheit is: " <<f;
cout<<"F"<<endl;
}
break;
}
cout<<"\n\nDone converting!"<<endl;
getch ();
}