In this challenge, you’ll write code that will use a formula to convert a temperature from degrees Fahrenheit to Celsius. You’ll print the result in a formatted message to the user.
Challenge: Calculate Celsius given the current temperature in Fahrenheit
- Select all of the code in the .NET Editor, and press Delete or Backspace to delete it.
- Enter the following code in the .NET Editor:C#Copy
int fahrenheit = 94; - To convert temperatures in degrees Fahrenheit to Celsius, first subtract 32, then multiply by five ninths (5 / 9).
- Display the result of the temperature conversion in a formatted messageCombine the variables with literal strings passed into a series of
Console.WriteLine()commands to form the complete message. - When you’re finished, the message should resemble the following output:OutputCopy
The temperature is 34.444444444444444444444444447 Celsius.
Leave a Reply