I have a form that calculates the salary bonus for a salary entered in a text box (bonus outputs in a label). I want to add the two together using a for loop statement and display as a label output. How do I go about doing this?
This is what I have for code.
void calculateBonus()
{
try
{
double salary = Convert.ToDouble(textBox1.Text.Trim());
if (salary <= 80000)
{
labelOutput.Text = "Employee bonus is $" + (salary * 0.4);
}
else if (salary <= 100000)
{
labelOutput.Text = "Employee bonus is $" + (salary * 0.6);
}
else
{
labelOutput.Text = "Employee bonus is $" + (salary * 0.8);
}
}catch(Exception ex)
{
MessageBox.Show("Please enter a number");
}
}
private void clearControls()
{
label1.Text = "";
textBox1.Text = "";
labelOutput.Text = "";
}
private void bonusToolStripMenuItem_Click(object sender, EventArgs e)
{
clearControls();
titleLabel.Text = "Calculate bonus";
label1.Text = "Enter employee salary amount";
toPerform = calculateBonus;
}
private void exitToolStripMenuItem_Click(object sender, EventArgs e)
{
Close();
}