59 lines
1.6 KiB
C#
Executable File
59 lines
1.6 KiB
C#
Executable File
namespace CelsiusAndFahrenheitTemperatureConverter_CalebFontenot
|
|
{
|
|
public partial class Form1 : Form
|
|
{
|
|
public Form1()
|
|
{
|
|
InitializeComponent();
|
|
}
|
|
|
|
private void buttonConvertCelsius_Click(object sender, EventArgs e)
|
|
{
|
|
try
|
|
{
|
|
// Define Vars
|
|
double celsius;
|
|
double fahrenheit;
|
|
|
|
// Get Data
|
|
//celsius = double.Parse(celsiusTextBox.Text);
|
|
fahrenheit = double.Parse(fahrenheitTextBox.Text);
|
|
|
|
// Calculate!
|
|
celsius = 5 / 9.0 * (fahrenheit - 32);
|
|
|
|
// Print output
|
|
celsiusTextBox.Text = celsius.ToString();
|
|
}
|
|
catch
|
|
{
|
|
MessageBox.Show("Invalid input!");
|
|
}
|
|
}
|
|
|
|
private void buttonConvertFahrenheit_Click(object sender, EventArgs e)
|
|
{
|
|
try
|
|
{
|
|
// Define Vars
|
|
double celsius;
|
|
double fahrenheit;
|
|
|
|
// Get Data
|
|
celsius = double.Parse(celsiusTextBox.Text);
|
|
//fahrenheit = double.Parse(fahrenheitTextBox.Text);
|
|
|
|
// Calculate!
|
|
fahrenheit = 9 / 5.0 * celsius + 32;
|
|
|
|
// Print output
|
|
fahrenheitTextBox.Text = fahrenheit.ToString();
|
|
}
|
|
catch
|
|
{
|
|
MessageBox.Show("Invalid input!");
|
|
}
|
|
}
|
|
|
|
}
|
|
} |