Write a C# Sharp program to convert from Celsius degrees to Kelvin and Fahrenheit.
kelvin = Celsius + 273
Fahrenheit = Celsius x 18 / 10 + 32
The units used to measure temperature are Celsius, kelvin and Fahrenheit. In routine life room temperature is measured in degree Celsius and human body temperature is measured in degree Fahrenheit. Thus it is usually needed to convert from one degree to another. For such conversion, there are some standard rules. Here are the formulas to convert temperature.
Celsius = 0.56 × (°Fahrenheit - 32)°
Fahrenheit = (1.8 × °Celsius) + 32
Kelvin = (273 + °Celsius)
Method:To convert temperature from one degree to another, the specified formula is used. First of all, input in Celsius degree is taken using ReadLine method of C# language. Then by using the standard formula, given value is converted into kelvin and Fahrenheit and displayed using WriteLine method of C# language.
Pseudo code:
define convert(x)
F = (x * 1.8) + 32
K = x + 273
Print F
Print K
Sample Solution:
C# Sharp Code:
using System;
public class Exercise1
{
public static void Main( )
{
Console.Write("Enter the amount of Celsius: ");
int celsius = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("Kelvin = {0}", celsius + 273);
Console.WriteLine("Fahrenheit = {0}", (celsius*1.8)+ 32);
}
}
Sample Output:
Enter the amount in Celcius: 40
Kelvin: 313
Fahrenheit: 104
Flowchart:
Here is the flowchart to convert temperature from one degree to the other.


No comments:
Post a Comment