Kelvin to Fahrenheit C++ converter
<p>I'm having trouble writing a program that will convert Kelvin to Fahrenheit. When I'm trying to convert Kelvin to Fahrenheit, I get a random output every time. Would someone please help me correct the issue? Thank you! </p>

<p>My first attempt:</p>

<pre><code>#include &lt;iostream&gt;

//using std::cout;
using namespace std;

float Convert(float TempFer);
float Convert2(float TempFer2);


int main()
{
    float TempFer;
    float TempCel;
  float TempKel;
    float TempFer2;
    int input;

    std::cout &lt;&lt; "Convert from Kelvin to Fahrenheit or Fahrenheit to Celsius?\n";
    std::cout &lt;&lt; "1. F to C\n";
    std::cout &lt;&lt; "2. K to F\n";
    cin &gt;&gt; input;

        switch (input) {
                case 1: 
    std::cout &lt;&lt; "Please enter the temperature in Fahrenheit: ";
    std::cin &gt;&gt; TempFer;
    TempCel = Convert(TempFer); // value of Tempfer passed inside function Convert
    std::cout &lt;&lt; "\nHere it is in Celsius: ";
    std::cout &lt;&lt; TempCel &lt;&lt; std::endl;
                break;

                     case 2:
                cout &lt;&lt; "Please enter temperature in Kelvin: ";
                cin &gt;&gt; TempKel;
                TempKel = Convert2(TempKel);
                cout &lt;&lt; "\nHere it is in Fahrenheit: ";
                cout &lt;&lt; TempFer2 &lt;&lt; std::endl;
                break;    



        }
    return 0;
}

float Convert(float TempFer) // value of Tempfer passed inside function Convert
{
    float TempCel;
    TempCel = ((TempFer - 32)*5) / 9;
    return TempCel;
}

   float Convert2(float TempKel)
{
        float TempFer2;
        TempFer2 = ((TempKel - 273.15)*9/5) + 32;
        return TempFer2;
}
</code></pre>

<p>My second attempt:</p>

<pre><code>#include &lt;iostream&gt;

//using std::cout;
using namespace std;

float Convert(float TempFer);
float Convert2(float TempFer2);
float TempKel;
float Fahrenheit;

void ConvertKel()
{
        Fahrenheit = (((TempKel - 273.15) * 9)/5) + 32;
}

int main()
{
    float TempFer;
    float TempCel;
  float TempKel;
    float TempFer2;
    int input;

    std::cout &lt;&lt; "Convert from Kelvin to Fahrenheit or Fahrenheit to Celsius?\n";
    std::cout &lt;&lt; "1. F to C\n";
    std::cout &lt;&lt; "2. K to F\n";
    cin &gt;&gt; input;

        switch (input) {
                case 1: 
    std::cout &lt;&lt; "Please enter the temperature in Fahrenheit: ";
    std::cin &gt;&gt; TempFer;
    TempCel = Convert(TempFer); // value of Tempfer passed inside function Convert
    std::cout &lt;&lt; "\nHere it is in Celsius: ";
    std::cout &lt;&lt; TempCel &lt;&lt; std::endl;
                break;

        /**     case 2:
                cout &lt;&lt; "Please enter temperature in Kelvin: ";
                cin &gt;&gt; TempKel;
                TempKel = Convert2(TempKel);
                cout &lt;&lt; "\nHere it is in Fahrenheit: ";
                cout &lt;&lt; TempFer2 &lt;&lt; std::endl;
                break;    **/

        case 2:
                cout &lt;&lt; "Please enter temperature in Kelvin: ";
                cin &gt;&gt; TempKel;
                ConvertKel();
                cout &lt;&lt; "\nHere it is in Fahrenheit: " &lt;&lt; Fahrenheit;
                break;

        }
    return 0;
}

float Convert(float TempFer) // value of Tempfer passed inside function Convert
{
    float TempCel;
    TempCel = ((TempFer - 32)*5) / 9;
    return TempCel;
}

/**float Convert2(float TempKel)
{
        float TempFer2;
        TempFer2 = ((TempKel - 273.15)*9/5) + 32;
        return TempFer2;
}
**/
</code></pre>
