/*
Escriba un programa que lea un valor de temperatura en K, ºC o ºF y la convierta 
a las otras dos escalas, lea el tipo de conversión mediante un menú y una sentencia switch.
*/

#include <iostream>
using namespace std;
int main() 
{
    float temp, centi, kel, fahre;
    int opci;
    cout << "PROGRAMA PARA ALLAR TEMPERATURA " << std::endl;
    cout<<"INGRESE TEMPERATURA "<<endl;
    cin>>temp;
    cout<<"INGRESE EN QUE SISTEMA"<<endl;
    cout<<"1.   KELVIN"<<endl;
    cout<<"2.   CENTIGRADOS"<<endl;
    cout<<"3.   FAHRENHEIT"<<endl;
    cout<<"INGRESE UNA OPCION "<<endl;
    cin>>opci;
    switch (opci)
    {
        case 1:
            //°C = K − 273.15
            centi=temp-273.15;
            //°F = (K − 273.15) × 9/5 + 32
            fahre=(((temp-273.15)*9/5)+32);
            cout<<"El valor en Centigrados es "<<""<<centi<<"c"<<endl;
            cout<<"El valor en FAHRENHEIT es "<<""<<fahre<<"f"<<endl;
            break;
        case 2:
            //K = °C + 273.15
            kel=temp+273.15;
            //°F = °C × 9/5 + 32
            fahre=temp*9/5+32;
            cout<<"El valor en KELVIN es "<<""<<kel<<"k"<<endl;
            cout<<"El valor en FAHRENHEIT es "<<""<<fahre<<"f"<<endl;
            break;
        case 3:
            //K = (°F − 32) × 5/9 + 273.15
            kel=(temp-32)*5/9+273.15;
            //°C = (°F − 32) × 5/9
            centi = (temp-32)*5/9;
            cout<<"El valor en KELVIN es "<<""<<kel<<"k"<<endl;
            cout<<"El valor en CENTIGRADOS es "<<""<<centi<<"c"<<endl;
            break;
        
    }
    
    
    return 0;
}

Embed on website

To embed this project on your website, copy the following code and paste it into your website's HTML: