Hello -
I'm not great at programming but I'm definitely worse at maths. I have been tyring to do this 'simple' salary calculator for so long that I am getting the numbers mixed up. I have had some of the calculations adding up correctly but not others and have now reached the point that I need to be put out of my misery. Any help gratefully received ...thank you:confused:
public partial class Calculator : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void wageCalculationBut_Click(object sender, EventArgs e)
{
//Declare the variables
float basicPay = 0;
float hoursWorked = float.Parse(hoursWorkedTextBox.Text);
float overtimePay = 0;
float estimatedWage = 0;
if (hoursWorked <= 40)
switch (jobTitleRbl.SelectedIndex)//Store the basicPay
{
case 0://Engineer working up to 40 hours
basicPay = hoursWorked * 10.0F;
break;
case 1://Senior Engineer working up to 40 hours
basicPay = hoursWorked * 12.0F;
break;
case 2://TechnicalEngineer working up to 40 hours
basicPay = 25.0F;
break;
case 3://Supervisor working up to 40 hours
basicPay = 30.0F;
break;
}
//Calcluations for overtimePay
if (jobTitleRbl.Items[0].Selected == true && hoursWorked > 40)//Engineer
basicPay = hoursWorked * 10.0F;
overtimePay = (hoursWorked - 40) * 1.5F;
if (jobTitleRbl.Items[1].Selected == true && hoursWorked > 40)//Senior Engineer
basicPay = 12.0F * 40;
overtimePay = (hoursWorked - 40) * 1.5F; //18.0F
if (jobTitleRbl.Items[2].Selected == true && hoursWorked > 40)//Technical Engineer
basicPay = 25.0F * 40;
overtimePay = (hoursWorked - 40) * 1.5F;// * 37.50F;
if (jobTitleRbl.Items[3].Selected == true && hoursWorked > 40)//Supervisor
basicPay = 30.0F * 40;
overtimePay = (hoursWorked - 40) * 1.5F;// * 45.0F;
//Add BEng bonus @ 10%
if (BEngCheckBox.Checked == true)
basicPay = basicPay * 1.1F;
estimatedWage = basicPay + overtimePay;
estimatedWageLab.Text = "Your estimated wage is " + estimatedWage.ToString("c");
}
}