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 "unreachable code detected". this code i guess is the calculation for my discount with the case declaration.
please help...
Expand|Select|Wrap|Line Numbers
- //Calculate Amount Discount with conditions
- amountDiscountDecimal = 0;
- if (singleUserRadioButton.Checked)
- {
- switch ("enterAmountDecimal")
- {
- case " >= 15":
- amountDiscountDecimal = Decimal.Round(
- (amountPurchasedDecimal * SINGLE_USER_DISCOUNT_RATE_Decimal), 2);
- break;
- case " < 15":
- amountDiscountDecimal = 0;
- break;
- }
- }
- else if (multipleUsersRadioButton.Checked)
- {
- if (numberOfUsersInteger >= 3)
- {
- switch ("enterAmountDecimal")
- {
- case " >= 45":
- amountDiscountDecimal = Decimal.Round(
- (amountPurchasedDecimal * MULTIPLE_USERS_DISCOUNT_RATE_Decimal), 2);
- break;
- case " < 45":
- amountDiscountDecimal = 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");
- numberOfUsersTextBox.Focus();
- numberOfUsersTextBox.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");
- }