Programming Fundamentals/Variables/C Sharp
Appearance
(Redirected from Computer Programming/Variables/C Sharp)
variables.cs
[edit | edit source]// This program converts a Fahrenheit temperature to Celsius.
//
// References:
// https://www.mathsisfun.com/temperature-conversion.html
// https://en.wikibooks.org/wiki/C_Sharp_Programming
using System;
public class Program
{
public static void Main(String[] args)
{
double fahrenheit;
double celsius;
Console.WriteLine("Enter Fahrenheit temperature:");
fahrenheit = Convert.ToDouble(Console.ReadLine());
celsius = (fahrenheit - 32) * 5 / 9;
Console.WriteLine(fahrenheit.ToString() + "° Fahrenheit is " +
celsius.ToString() + "° Celsius");
}
}
Try It
[edit | edit source]Copy and paste the code above into one of the following free online development environments or use your own C Sharp compiler / interpreter / IDE.