Programming Fundamentals/Functions/C Sharp: Difference between revisions
Jump to navigation
Jump to search
Content deleted Content added
Creating |
(No difference)
|
Revision as of 04:50, 19 January 2017
subroutines.cs
using System;
class MainClass {
public static void Main (string[] args) {
double f;
double c;
f = GetF();
c = CalculateC(f);
DisplayResult(f, c);
}
private static double GetF()
{
string input;
double f;
Console.WriteLine("Enter Fahrenheit temperature:");
input = Console.ReadLine();
f = Convert.ToDouble(input);
return f;
}
private static double CalculateC(double f)
{
double c;
c = (f - 32) * 5 / 9;
return c;
}
private static void DisplayResult(double f, double c)
{
Console.WriteLine(f.ToString() + "° Fahrenheit is " + c + "° Celsius");
}
}
Try It
Copy and paste the code above into one of the following free online development environments or use your own C Sharp compiler / interpreter / IDE.