how do i get over this warning to get my program running correctly??
Below is the faulty part of the code. Am trying to calculate discount on a purchase form. the codes for my discount is nested in an if statement with a switch case involved. how ever upon executing, my form dosent calculate the discount due to the warning that says "unreachabl e code detected". this code i guess is the calculation for my discount with the case declaration.
please help...
[code=c#]
//Calculate Amount Discount with conditions
amountDiscountD ecimal = 0;
if (singleUserRadi oButton.Checked )
{
switch ("enterAmountDe cimal")
{
case " >= 15":
amountDiscountD ecimal = Decimal.Round(
(amountPurchase dDecimal * SINGLE_USER_DIS COUNT_RATE_Deci mal), 2);
break;
case " < 15":
amountDiscountD ecimal = 0;
break;
}
}
else if (multipleUsersR adioButton.Chec ked)
{
if (numberOfUsersI nteger >= 3)
{
switch ("enterAmountDe cimal")
{
case " >= 45":
amountDiscountD ecimal = Decimal.Round(
(amountPurchase dDecimal * MULTIPLE_USERS_ DISCOUNT_RATE_D ecimal), 2);
break;
case " < 45":
amountDiscountD ecimal = 0;
break;
}
}
else
{
//Display error message if users are less than 3
MessageBox.Show ("Number of users must be more than 3.", "Data Entry Error");
numberOfUsersTe xtBox.Focus();
numberOfUsersTe xtBox.SelectAll ();
}
}
else
{
//display error message if no user type is selected
MessageBox.Show ("Please select user type and enter amount to calculate discount.", "Required Entry");
}
[/code]
Below is the faulty part of the code. Am trying to calculate discount on a purchase form. the codes for my discount is nested in an if statement with a switch case involved. how ever upon executing, my form dosent calculate the discount due to the warning that says "unreachabl e code detected". this code i guess is the calculation for my discount with the case declaration.
please help...
[code=c#]
//Calculate Amount Discount with conditions
amountDiscountD ecimal = 0;
if (singleUserRadi oButton.Checked )
{
switch ("enterAmountDe cimal")
{
case " >= 15":
amountDiscountD ecimal = Decimal.Round(
(amountPurchase dDecimal * SINGLE_USER_DIS COUNT_RATE_Deci mal), 2);
break;
case " < 15":
amountDiscountD ecimal = 0;
break;
}
}
else if (multipleUsersR adioButton.Chec ked)
{
if (numberOfUsersI nteger >= 3)
{
switch ("enterAmountDe cimal")
{
case " >= 45":
amountDiscountD ecimal = Decimal.Round(
(amountPurchase dDecimal * MULTIPLE_USERS_ DISCOUNT_RATE_D ecimal), 2);
break;
case " < 45":
amountDiscountD ecimal = 0;
break;
}
}
else
{
//Display error message if users are less than 3
MessageBox.Show ("Number of users must be more than 3.", "Data Entry Error");
numberOfUsersTe xtBox.Focus();
numberOfUsersTe xtBox.SelectAll ();
}
}
else
{
//display error message if no user type is selected
MessageBox.Show ("Please select user type and enter amount to calculate discount.", "Required Entry");
}
[/code]
Comment