Question: I am working with `ViewPager` i.e on top of the `MainActivity` class and the `Viewpager` class extends fragment.

The problem is that, normally when we need a class to return some `result` then while passing the `intent` we use `startActivityforresult(intent,int)` hence it passes the result captured in the secondactivity the class from where it's been called.

**But as i am working with viewpager on top of the mainactivity and i am using `floating action button`, when i click the button to open the second activity it returns the result to the mainactivity but not the viewpager class.**

> 
> **So my question is how can i pass the result taken from the secondactivity to my desired class?**
> 
> 
> 

**Update::**
`MainActivity.java`
this is my main class which is using the intent as well as receiving the result from the second activity class `ActivityTwo`

What i have done here is 

```
startActivityForResult(intent,1);
public void onActivityresult(i,j,intent){MyFragment fragment;
fragment.onActivityReusult(i,j,intent);//Here i have passes the values      
received by this class to the fragment class where i need the values but it's not working
}

```

Answer: 
Some suggested improvements:

```
BEGIN {
    split("KS .07 MO .08",tmp)
    for (i=1;i in tmp;i+=2)
        taxRate[tmp[i]] = tmp[i+1]
    fmtS = "%12s%s\n"
    fmtF = "%12s$%.2f\n"
}
NR>1 {
    name=$1" "$2
    state=$3
    payRate=$4
    hoursWorked=$5
    overtime=$6

    grossPay=(hoursWorked+(overtime*1.5))*payRate
    tax = grossPay* taxRate[state]
    netPay = grossPay-tax

    printf fmtS, "Name", "State"
    printf fmtS, name, state
    printf fmtF, "Gross Pay:", grossPay
    printf fmtF, "Taxes:", tax
    printf fmtF, "Net Pay:", netPay
}
END {
    print "\n-complete-"
}

```
Thanks to zzevann here's my final code

```
#!/bin/awk -f

#Skips the first line
NR==1{next;}
{
        name=$1" "$2
        state=$3
        payRate=$4
        hoursWorked=$5
        overtime=$6

        grossPay=(hoursWorked+(overtime*1.5))*payRate
        if (state == "KS")
                tax = grossPay* .07
        else if (state == "MO")
                tax = grossPay* .08
        else
                tax = 0
                #If tax reads 0 you KNOW something's wrong

        netPay = grossPay-tax

        print "\nName     \tState"
        print name, "\t" state,
        "\nGross Pay:\t$" grossPay,
        "\nTaxes:     \t$" tax,
        "\nNet Pay:\t$" netPay
}
END{
        print "\n-complete-"
}

```

with the final output

```
Name        State
John Doe    MO 
Gross Pay:  $371.25 
Taxes:      $29.7 
Net Pay:    $341.55

Name        State
Jane Doe    KS 
Gross Pay:  $672 
Taxes:      $47.04 
Net Pay:    $624.96

Name        State
Sam Smith   MO 
Gross Pay:  $1690 
Taxes:      $135.2 
Net Pay:    $1554.8

Name        State
Barb Jones  MO 
Gross Pay:  $1808 
Taxes:      $144.64 
Net Pay:    $1663.36

Name        State
Jenny Lind  KS 
Gross Pay:  $294 
Taxes:      $20.58 
Net Pay:    $273.42

```