namespace Lab3_2_CalebFontenot { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void calculateButton_Click(object sender, EventArgs e) { double miles; double gallons; double mpg; // Validate the milesTextBox control. if (double.TryParse(milesTextBox.Text, out miles)) { if (double.TryParse(gallonsTextBox.Text, out gallons)) { // Calculate MPG. mpg = miles / gallons; // Display the MPG in the mpgLabel control. mpgLabel.Text = mpg.ToString("n1"); } else { // Display an error message for gallonsTextBox. MessageBox.Show("Invalid input for gallons."); } } else { // Display an error message for milesTextBox. MessageBox.Show("Invalid input for miles."); } } private void exitButton_Click(object sender, EventArgs e) { // Close the form. this.Close(); } } }