making switch “if” statements

I’m making a Pay Calculator for my companies employees. It takes Federal Tax, Social Security Tax, and Medicare Tax into consideration. However, some of the employees are independent contractors and do not pay certain taxes. Thus all of these taxes are on their separate switch button. I’m having trouble making the “if” statements for these switches, because I have never done a switch before. I’m hoping someone could lead me in the right direction!


  • iOS Bluetooth dual-mode; connect BLE (GATT) to an already connected BR/EDR (A2DP/HFP) stereo headset simultaneously
  • What is the type of SCNVector3 components? CGFloat or Float?
  • Receiver has no segue with identifier execption
  • Open app with iBeacon
  • What is the best way to build a complex NSCompoundPredicate?
  • Cordova Plugin Whitelist Failed asking for cordova ios 4
  • - (IBAction)calculateButtonPressed:(UIButton *)sender
        float dailyRate = [self.dailyRateTextField.text floatValue];
        float daysWorked = [self.daysWorkedTextField.text floatValue];
        float grossPay = dailyRate * daysWorked;
        float taxRate = .72;
        float ssRate = .938;
        float medRate = .9855;
        float netPay = grossPay * taxRate * medRate * ssRate;
        self.dailyRateTextField.text = [NSString stringWithFormat:@"$%.2f", dailyRate];
        self.netIncomeTextField.text = [NSString stringWithFormat:@"$%.2f", netPay];
        self.grossIncomeTextField.text = [NSString stringWithFormat:@"$%.2f", grossPay];
        if (fedTaxSwitchOutlet.on) {}
        if (!fedTaxSwitchOutlet.on) {}
        if (ssTaxSwitchOutlet.on){}
        if (!ssTaxSwitchOutlet.on) {}
        if (medTaxSwitchOutlet.on) {}
        if (!medTaxSwitchOutlet.on) {}

    Does anyone know how I would do an equation in the “if” statement? Like if the Medicare Tax Switch is turned off I still would like the app to calculate the persons the social security tax and the federal tax.

    2 Solutions Collect From Internet About “making switch “if” statements”

    Declare your variables above your if statement. This allows you to read them within the if statements, this is called scope. If you’re going to continue working on this project, please read up about the basics of variable scope.

    Also if you don’t need to do anything if the UISwitch is off, then don’t look for it – all you need to do is see if the switch is on. If it is, then calculate.

    float federal = 0.0;
    float socialSecurity = 0.0;
    float medicare = 0.0;
    if (fedTaxSwitchOutlet.on) {
      federal = [self calculateFederal]
    if (ssTaxSwitchOutlet.on){
      socialSecurity = [self calculateSocialSecurity]
    if (medTaxSwitchOutlet.on) {
      medicare = [self calculateMedicare];
    float total = federal + socialSecurity + medicare;

    @Yogesh Suthar was right, heres what I did:

    if (medTaxSwitchOutlet.on) netPay = netPay;
    else netPay = netPay + medgrossrate;
    if (ssTaxSwitchOutlet.on) netPay = netPay;
    else netPay = netPay + ssgrossrate;
    if (fedTaxSwitchOutlet.on) netPay = netPay;
    else netPay = netPay + minusTaxes;