Created
August 12, 2012 00:44
-
-
Save anonymous/3328254 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.ComponentModel; | |
using System.Data; | |
using System.Drawing; | |
using System.Linq; | |
using System.Text; | |
using System.Windows.Forms; | |
namespace TemperatureConversion | |
{ | |
public partial class Form1 : Form | |
{ | |
public Form1() | |
{ | |
InitializeComponent(); | |
} | |
private void button1_Click(object sender, EventArgs e) | |
{ | |
//Calculate button | |
double input = Convert.ToDouble(textBox1.Text); | |
if (checkBox1.Checked) | |
{ | |
textBox2.Text = input.ToString(); | |
textBox3.Text = FahrenheitCelsius(input).ToString(); | |
textBox4.Text = FahrenheitKelvin(input).ToString(); | |
textBox5.Text = FahrenheitRankine(input).ToString(); | |
} | |
if (checkBox2.Checked) | |
{ | |
textBox2.Text = CelsiusFahrenheit(input).ToString(); | |
textBox3.Text = input.ToString(); | |
textBox4.Text = CelsiusKelvin(input).ToString(); | |
textBox5.Text = CelsiusRankine(input).ToString(); | |
} | |
if (checkBox3.Checked) | |
{ | |
textBox2.Text = KelvinFahrenheit(input).ToString(); | |
textBox3.Text = KelvinCelsius(input).ToString(); | |
textBox4.Text = input.ToString(); | |
textBox5.Text = KelvinRankine(input).ToString(); | |
} | |
if (checkBox4.Checked) | |
{ | |
textBox2.Text = RankineFahrenheit(input).ToString(); | |
textBox3.Text = RankineCelsius(input).ToString(); | |
textBox4.Text = RankineKelvin(input).ToString(); | |
} | |
} | |
public static double FahrenheitCelsius(double Fahrenheit) | |
{ | |
double FahrenheitCelsius; | |
FahrenheitCelsius = ((Fahrenheit - 32) * (5/9)); | |
Math.Round(FahrenheitCelsius, 2); | |
return FahrenheitCelsius; | |
} | |
public static double FahrenheitKelvin(double Fahrenheit) | |
{ | |
double FahrenheitKelvin; | |
FahrenheitKelvin = ((Fahrenheit + 459.67) * (5/9)); | |
Math.Round(FahrenheitKelvin, 2); | |
return FahrenheitKelvin; | |
} | |
public static double FahrenheitRankine(double Fahrenheit) | |
{ | |
double FahrenheitRankine; | |
FahrenheitRankine = Fahrenheit + 459.67; | |
Math.Round(FahrenheitRankine, 2); | |
return FahrenheitRankine; | |
} | |
public static double CelsiusFahrenheit(double Celsius) | |
{ | |
double CelsiusFahrenheit; | |
CelsiusFahrenheit = (Celsius * (9 / 5) + 32); | |
Math.Round(CelsiusFahrenheit, 2); | |
return CelsiusFahrenheit; | |
} | |
public static double CelsiusKelvin(double Celsius) | |
{ | |
double CelsiusKelvin; | |
CelsiusKelvin = (Celsius + 273.15); | |
Math.Round(CelsiusKelvin, 2); | |
return CelsiusKelvin; | |
} | |
public static double CelsiusRankine(double Celsius) | |
{ | |
double CelsiusRankine; | |
CelsiusRankine = ((Celsius + 273.15) * (9 / 5)); | |
Math.Round(CelsiusRankine, 2); | |
return CelsiusRankine; | |
} | |
public static double KelvinFahrenheit(double Kelvin) | |
{ | |
double KelvinFahrenheit; | |
KelvinFahrenheit = (Kelvin * (9 / 5) - 459.67); | |
Math.Round(KelvinFahrenheit, 2); | |
return KelvinFahrenheit; | |
} | |
public static double KelvinCelsius(double Kelvin) | |
{ | |
double KelvinCelsius; | |
KelvinCelsius = (Kelvin - 273.15); | |
Math.Round(KelvinCelsius, 2); | |
return KelvinCelsius; | |
} | |
public static double KelvinRankine(double Kelvin) | |
{ | |
double KelvinRankine; | |
KelvinRankine = (Kelvin * (9 / 5)); | |
Math.Round(KelvinRankine, 2); | |
return KelvinRankine; | |
} | |
public static double RankineFahrenheit(double Rankine) | |
{ | |
double RankineFahrenheit; | |
RankineFahrenheit = (Rankine - 459.67); | |
Math.Round(RankineFahrenheit, 2); | |
return RankineFahrenheit; | |
} | |
public static double RankineCelsius(double Rankine) | |
{ | |
double RankineCelsius; | |
RankineCelsius = ((Rankine - 491.67) * (5 / 9)); | |
Math.Round(RankineCelsius, 2); | |
return RankineCelsius; | |
} | |
public static double RankineKelvin(double Rankine) | |
{ | |
double RankineKelvin; | |
RankineKelvin = (Rankine * (5/9)); | |
Math.Round(RankineKelvin, 2); | |
return RankineKelvin; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment