ASDV-C-Sharp/Lab4_1/Lab4_1_CalebFontenot/Form1.cs
2022-09-13 15:08:17 -05:00

68 lines
2.1 KiB
C#
Executable File

namespace Lab4_1_CalebFontenot
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void calculateButton_Click(object sender, EventArgs e)
{
try
{
// Setup variables
double test1Score,
test2Score,
test3Score,
average;
const double HIGH_SCORE = 95.0,
LOW_SCORE = 68.0;
// Get data
test1Score = double.Parse(test1TextBox.Text);
test2Score = double.Parse(test2TextBox.Text);
test3Score = double.Parse(test3TextBox.Text);
// Calculate the average test score:
average = (test1Score + test2Score + test3Score) / 3.0;
// Print output in text box:
averageLabel.Text = average.ToString("n1");
// If the average is high, congratulate the user :pogchamp:
if (average > HIGH_SCORE)
{
MessageBox.Show("Congratulations! Great job! I may just be a message box, but I'm proud of you!");
}
if (average < LOW_SCORE)
{
MessageBox.Show("Lol get rekt");
}
}
catch (Exception ex)
{
// Display the default error message.
MessageBox.Show(ex.Message);
}
}
private void clearButton_Click(object sender, EventArgs e)
{
// Clear the text boxes
test1TextBox.Text = "";
test2TextBox.Text = "";
test3TextBox.Text = "";
averageLabel.Text = "";
// Reset the focus to test1.
test1TextBox.Focus();
}
private void exitButton_Click(object sender, EventArgs e)
{
this.Close();
}
}
}