implement a C# method
TemperatureConverter(
double
tempInCelsius
)
which
accepts the temperature in Celsius as input parameter and returns the temperature in
Fahrenheit
as the output value.
Note:
T
(°F)
=
T
(°C)
× 1.8 + 32
Sample Input
Expected Output
tempInCelsius = 32
89.6
using System;
namespace Temp_conv
{
class Program
{
public static double TemperatureConverter(double tempInCelsius)
{
double Fahrenheit = tempInCelsius * 1.8 + 32;
return (Fahrenheit);
}
public static void Main(string[] args)
{
double Celsius;
Console.Write("tempInCelsius = ");
Celsius = Convert.ToDouble(Console.ReadLine());
Console.WriteLine("Temperature in Fahrenheit = {0}", TemperatureConverter(Celsius));
Console.Write("Press any key to continue . . . ");
Console.ReadKey(true);
}
}
}
Comments
Leave a comment