Convert kelvin to fahrenheit

Here given code implementation process.

//C Program 
//Convert kelvin to fahrenheit
#include <stdio.h>

//Find the fahrenheit by given kelvin
void kelvin_to_fahrenheit(double kelvin)
{
	// Formula : (kelvin - 273.15) * (9/5) + 32
	// Calculate given kelvin to fahrenheit 
	double fahrenheit = (kelvin - 273.15) * (9 / 5.0) + 32;
	//Display result
	printf("Kelvin : %lf  Fahrenheit : %lf\n", kelvin, fahrenheit);
}
int main()
{
	//Simple test
	kelvin_to_fahrenheit(1);
	kelvin_to_fahrenheit(604.5);
	kelvin_to_fahrenheit(280.90);
	return 0;
}

Output

Kelvin : 1.000000  Fahrenheit : -457.870000
Kelvin : 604.500000  Fahrenheit : 628.430000
Kelvin : 280.900000  Fahrenheit : 45.950000
/*
  Java program
  Convert kelvin to fahrenheit
*/
class MyMath
{
	//Find the fahrenheit by given kelvin
	public void kelvin_to_fahrenheit(double kelvin)
	{
		// Formula : (kelvin - 273.15) * (9/5) + 32
		// Calculate given kelvin to fahrenheit 
		double fahrenheit = (kelvin - 273.15) * (9 / 5.0) + 32;
		System.out.print("Kelvin : " + kelvin + " fahrenheit : " + fahrenheit + "\n");
	}
	public static void main(String[] args)
	{
		MyMath obj = new MyMath();
		//Simple test
		obj.kelvin_to_fahrenheit(1);
		obj.kelvin_to_fahrenheit(604.5);
		obj.kelvin_to_fahrenheit(280.90);
	}
}

Output

Kelvin : 1.0 fahrenheit : -457.86999999999995
Kelvin : 604.5 fahrenheit : 628.4300000000001
Kelvin : 280.9 fahrenheit : 45.95
/*
  C++ program
  Convert kelvin to fahrenheit
*/
#include<iostream>

using namespace std;
class MyMath
{
	public:
		//Find the fahrenheit by given kelvin
		void kelvin_to_fahrenheit(double kelvin)
		{
			// Formula : (kelvin - 273.15) * (9/5) + 32
			// Calculate given kelvin to fahrenheit 
			double fahrenheit = (kelvin - 273.15) * (9 / 5.0) + 32;
			cout << "Kelvin : " << kelvin << " fahrenheit : " << fahrenheit << "\n";
		}
};
int main()
{
	MyMath obj ;
	//Simple test
	obj.kelvin_to_fahrenheit(1);
	obj.kelvin_to_fahrenheit(604.5);
	obj.kelvin_to_fahrenheit(280.90);
	return 0;
}

Output

Kelvin : 1 fahrenheit : -457.87
Kelvin : 604.5 fahrenheit : 628.43
Kelvin : 280.9 fahrenheit : 45.95
/*
  C# program
  Convert kelvin to fahrenheit
*/
using System;
class MyMath
{
	//Find the fahrenheit by given kelvin
	public void kelvin_to_fahrenheit(double kelvin)
	{
		// Formula : (kelvin - 273.15) * (9/5) + 32
		// Calculate given kelvin to fahrenheit 
		double fahrenheit = (kelvin - 273.15) * (9 / 5.0) + 32;
		Console.Write("Kelvin : " + kelvin + " fahrenheit : " + fahrenheit + "\n");
	}
	public static void Main(String[] args)
	{
		MyMath obj = new MyMath();
		//Simple test
		obj.kelvin_to_fahrenheit(1);
		obj.kelvin_to_fahrenheit(604.5);
		obj.kelvin_to_fahrenheit(280.90);
	}
}

Output

Kelvin : 1 fahrenheit : -457.87
Kelvin : 604.5 fahrenheit : 628.43
Kelvin : 280.9 fahrenheit : 45.95
<?php
/*
  Php program
  Convert kelvin to fahrenheit
*/
class MyMath
{
	//Find the fahrenheit by given kelvin
	public	function kelvin_to_fahrenheit($kelvin)
	{
		// Formula : (kelvin - 273.15) * (9/5) + 32
		// Calculate given kelvin to fahrenheit 
		$fahrenheit = ($kelvin - 273.15) * (9 / 5.0) + 32;
		echo "Kelvin : ". $kelvin ." fahrenheit : ". $fahrenheit ."\n";
	}
}

function main()
{
	$obj = new MyMath();
	//Simple test
	$obj->kelvin_to_fahrenheit(1);
	$obj->kelvin_to_fahrenheit(604.5);
	$obj->kelvin_to_fahrenheit(280.90);
}
main();

Output

Kelvin : 1 fahrenheit : -457.87
Kelvin : 604.5 fahrenheit : 628.43
Kelvin : 280.9 fahrenheit : 45.95
/*
  Node Js program
  Convert kelvin to fahrenheit
*/
class MyMath
{
	//Find the fahrenheit by given kelvin
	kelvin_to_fahrenheit(kelvin)
	{
		// Formula : (kelvin - 273.15) * (9/5) + 32
		// Calculate given kelvin to fahrenheit 
		var fahrenheit = (kelvin - 273.15) * (9 / 5) + 32;
		process.stdout.write("Kelvin : " + kelvin + " fahrenheit : " + fahrenheit + "\n");
	}
}

function main()
{
	var obj = new MyMath();
	//Simple test
	obj.kelvin_to_fahrenheit(1);
	obj.kelvin_to_fahrenheit(604.5);
	obj.kelvin_to_fahrenheit(280.90);
}
main();

Output

Kelvin : 1 fahrenheit : -457.86999999999995
Kelvin : 604.5 fahrenheit : 628.4300000000001
Kelvin : 280.9 fahrenheit : 45.95
#   Python 3 program
#   Convert kelvin to fahrenheit

class MyMath :
	# Find the fahrenheit by given kelvin
	def kelvin_to_fahrenheit(self, kelvin) :
		#  Formula : (kelvin - 273.15) * (9/5) + 32
		#  Calculate given kelvin to fahrenheit 
		fahrenheit = (kelvin - 273.15) * (9 / 5) + 32
		print("Kelvin : ", kelvin ," fahrenheit : ", fahrenheit ,"\n", end = "")
	

def main() :
	obj = MyMath()
	# Simple test
	obj.kelvin_to_fahrenheit(1)
	obj.kelvin_to_fahrenheit(604.5)
	obj.kelvin_to_fahrenheit(280.90)

if __name__ == "__main__": main()

Output

Kelvin :  1  fahrenheit :  -457.86999999999995
Kelvin :  604.5  fahrenheit :  628.4300000000001
Kelvin :  280.9  fahrenheit :  45.95
#   Ruby program
#   Convert kelvin to fahrenheit

class MyMath

	# Find the fahrenheit by given kelvin
	def kelvin_to_fahrenheit(kelvin)
	
		#  Formula : (kelvin - 273.15) * (9/5) + 32
		#  Calculate given kelvin to fahrenheit 
		fahrenheit = (kelvin - 273.15) * (9 / 5.0) + 32
		print("Kelvin : ", kelvin ," fahrenheit : ", fahrenheit ,"\n")
	end
end
def main()

	obj = MyMath.new()
	# Simple test
	obj.kelvin_to_fahrenheit(1)
	obj.kelvin_to_fahrenheit(604.5)
	obj.kelvin_to_fahrenheit(280.90)
end
main()

Output

Kelvin : 1 fahrenheit : -457.86999999999995
Kelvin : 604.5 fahrenheit : 628.4300000000001
Kelvin : 280.9 fahrenheit : 45.95
/*
  Scala program
  Convert kelvin to fahrenheit
*/
class MyMath
{
	//Find the fahrenheit by given kelvin
	def kelvin_to_fahrenheit(kelvin: Double): Unit = {
		// Formula : (kelvin - 273.15) * (9/5) + 32
		// Calculate given kelvin to fahrenheit 
		var fahrenheit: Double = (kelvin - 273.15) * (9 / 5.0) + 32;
		print("Kelvin : " + kelvin + " fahrenheit : " + fahrenheit + "\n");
	}
}
object Main
{
	def main(args: Array[String]): Unit = {
		var obj: MyMath = new MyMath();
		//Simple test
		obj.kelvin_to_fahrenheit(1);
		obj.kelvin_to_fahrenheit(604.5);
		obj.kelvin_to_fahrenheit(280.90);
	}
}

Output

Kelvin : 1.0 fahrenheit : -457.86999999999995
Kelvin : 604.5 fahrenheit : 628.4300000000001
Kelvin : 280.9 fahrenheit : 45.95
/*
  Swift program
  Convert kelvin to fahrenheit
*/
class MyMath
{
	//Find the fahrenheit by given kelvin
	func kelvin_to_fahrenheit(_ kelvin: Double)
	{
		// Formula : (kelvin - 273.15) * (9/5) + 32
		// Calculate given kelvin to fahrenheit 
		let fahrenheit: Double = (kelvin - 273.15) * (9 / 5.0) + 32;
		print("Kelvin : ", kelvin ," fahrenheit : ", fahrenheit ,"\n", terminator: "");
	}
}
func main()
{
	let obj: MyMath = MyMath();
	//Simple test
	obj.kelvin_to_fahrenheit(1);
	obj.kelvin_to_fahrenheit(604.5);
	obj.kelvin_to_fahrenheit(280.90);
}
main();

Output

Kelvin :  1.0  fahrenheit :  -457.87
Kelvin :  604.5  fahrenheit :  628.43
Kelvin :  280.9  fahrenheit :  45.95


Please share your knowledge to improve code and content standard. Also submit your doubts, and test case. We improve by your feedback. We will try to resolve your query as soon as possible.

New Comment







© 2021, kalkicode.com, All rights reserved