Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 4

#include <bits/stdc++.

h>
using namespace std;

float
celsiusToKelvin (float celsius)
{
return celsius + 273.15;
}

float
kelvinToCelsius (float kelvin)
{
return kelvin - 273.15;
}

float
celsiusToFahrenheit (float celsius)
{
return (celsius * 9 / 5) + 32;
}

float
fahrenheitToCelsius (float fahrenheit)
{
return (fahrenheit - 32) * 5 / 9;
}

float
kelvinToFahrenheit (float kelvin)
{
return celsiusToFahrenheit (kelvinToCelsius (kelvin));
}

float
fahrenheitToKelvin (float fahrenheit)
{
return celsiusToKelvin (fahrenheitToCelsius (fahrenheit));
}

float
kelvinToRankine (float kelvin)
{
return kelvin * 9.0 / 5.0;
}

float
celsiusToRankine (float celsius)
{
return (celsius + 273.15) * 9.0 / 5.0;
}

float
fahrenheitToRankine (float fahrenheit)
{
return fahrenheit + 459.67;
}

float
rankineToCelsius (float rankine)
{
return (rankine - 491.67f) * 5.0f / 9.0f;
}

float
rankineToFahrenheit (float rankine)
{
return rankine - 459.67f;
}

float
rankineToKelvin (float rankine)
{
return rankine * 5.0f / 9.0f;
}

int main ()
{
float temperature;
int choice;
int flag = 1;
cout << "Temperature Conversion Program" << endl;
cout<<endl;

cout << "1. Celsius to Kelvin" << endl;


cout << "2. Kelvin to Celsius" << endl;
cout << "3. Celsius to Fahrenheit" << endl;
cout << "4. Fahrenheit to Celsius" << endl;
cout << "5. Kelvin to Fahrenheit" << endl;
cout << "6. Fahrenheit to Kelvin" << endl;
cout << "7. Rankine to Kelvin" << endl;
cout << "8. Rankine to Celsius" << endl;
cout << "9. Rankine to Fahrenheit" << endl;
cout << "10.Kelvin to Rankine" << endl;
cout << "11.Celsius to Rankine" << endl;
cout << "12.Fahrenheit to Rankine" << endl;
cout<<endl;
cout << "Enter your choice: ";
cin >> choice;
cout << endl;
cout << endl;
if (choice >= 1 and choice <= 12)
{
cout << "Enter temperature: ";
cin >> temperature;

}
switch (choice)
{
case 1:
cout << temperature << " Celsius is " <<
celsiusToKelvin (temperature) << " Kelvin." << endl;
break;
case 2:
cout << temperature << " Kelvin is " <<
kelvinToCelsius (temperature) << " Celsius." << endl;
break;
case 3:
cout << temperature << " Celsius is " <<
celsiusToFahrenheit (temperature) << " Fahrenheit." << endl;
break;
case 4:
cout << temperature << " Fahrenheit is " <<
fahrenheitToCelsius (temperature) << " Celsius." << endl;
break;
case 5:
cout << temperature << " Kelvin is " <<
kelvinToFahrenheit (temperature) << " Fahrenheit." << endl;
break;
case 6:
cout << temperature << " Fahrenheit is " <<
fahrenheitToKelvin (temperature) << " Kelvin." << endl;
break;
case 7:
cout << temperature << " Rankine is " <<
rankineToKelvin (temperature) << " Kelvin." << endl;
break;
case 8:
cout << temperature << " Rankine is " <<
rankineToCelsius (temperature) << " Celsius." << endl;
break;
case 9:
cout << temperature << " Rankine is " <<
rankineToFahrenheit (temperature) << " Fahrenheit." << endl;
break;
case 10:
cout << temperature << " Kelvin is " <<
kelvinToRankine (temperature) << " Rankine." << endl;
break;
case 11:
cout << temperature << " Celsius is " <<
celsiusToRankine (temperature) << " Rankine." << endl;
break;
case 12:
cout << temperature << " Fahrenheit is " <<
fahrenheitToRankine (temperature) << " Rankine." << endl;
break;
default:
cout << "Invalid choice." << endl;
cout << endl;
cout << endl;
main ();
}

return 0;
}

You might also like