📜  华氏到开尔文转换程序

📅  最后修改于: 2022-05-13 01:57:58.800000             🧑  作者: Mango

华氏到开尔文转换程序

给定华氏温度,我们的任务是将其转换为开尔文温度。
例子 :

Input : F = 100
Output : K = 311.278

Input : F = 110
Output : K = 316.833

从华氏 (F) 到开尔文 (K) 的温度转换由以下公式给出:

K = 273.5 + ((F - 32.0) * (5.0/9.0))

C++
// CPP program to convert temperature from
// Fahrenheit to Kelvin
#include
using namespace std ;
 
// Function to convert temperature from degree
// Fahrenheit to Kelvin
float Fahrenheit_to_Kelvin( float F )
{
    return 273.5 + ((F - 32.0) * (5.0/9.0));
}
 
// Driver function
int main()
{
    float F = 100;
    cout << "Temperature in Kelvin ( K ) = "
          << Fahrenheit_to_Kelvin( F ) ;
    return 0;
}


Java
// Java program to convert temperature
// from Fahrenheit to Kelvin
class GFG
{
 
// Function to convert temperature 
// from degree Fahrenheit to Kelvin
static float Fahrenheit_to_Kelvin( float F )
{
    return 273.5f + ((F - 32.0f) * (5.0f/9.0f));
}
 
// Driver code
public static void main(String arg[])
{
    float F = 100;
    System.out.print("Temperature in Kelvin ( K ) = "
                    + (Math.round(Fahrenheit_to_Kelvin( F )
                                        *1000.0)/1000.0)) ;
}
}
// This code is contributed by Anant Agarwal.


Python
# Python program to convert temperature from
# Fahrenheit to Kelvin
 
# Function to convert temperature
def Fahrenheit_to_Kelvin(F):
    return 273.5 + ((F - 32.0) * (5.0/9.0))
 
# Driver function
F = 100
print("Temperature in Kelvin ( K ) = {:.3f}"
            .format(Fahrenheit_to_Kelvin( F )))


C#
// C# program to convert temperature
// from Fahrenheit to Kelvin
using System;
 
class GFG
{
 
// Function to convert temperature
// from degree Fahrenheit to Kelvin
static float Fahrenheit_to_Kelvin( float F )
{
    return 273.5f + ((F - 32.0f) *
                    (5.0f/9.0f));
}
 
// Driver code
public static void Main()
{
    float F = 100;
    Console.WriteLine("Temperature in Kelvin (K) = "
                    + (Math.Round(Fahrenheit_to_Kelvin(F)
                                        *1000.0)/1000.0)) ;
}
}
 
// This code is contributed by vt_m.


PHP


Javascript


输出 :

Temperature in Kelvin ( K ) = 311.278