Question 4: Convert temperature Fahrenheit (F) to Celsius (C).
Vary Fahrenheit from 32 to 212, Compute Celsius and display both.
Formula: C = 5 * (F-32)/9 (use float or double)
static void Main(string[] args)
{
double F = 32;
while (F >= 32 && F <= 200)
{
double C = 5 * (F - 32) / 9;
Console.WriteLine("Fahrenheit: {0} -- {1:f1} Celsius", F, C);
F++;
}
Console.ReadKey();
}
No comments:
Post a Comment