AWK way of calculating growth

Hi All,
IS there any 'awk' way to manipulate following data?

Fruit Date Count
Apple 20/08/2011 5
Apple 27/08/2011 7
Apple 05/09/2011 11
Apple 12/09/2011 3
Apple 19/09/2011 25
.
.
.
.
Orange 20/08/2011 9
Orange 27/08/2011 20
Orange 27/08/2011 7
Orange 05/09/2011 15
Orange 12/09/2011 24
.
.
.
And so on.

I need to manipulation on above data-
Fruit Date Count Difference
Apple 20/08/2011 5 0
Apple 27/08/2011 7 2
Apple 05/09/2011 11 4
Apple 12/09/2011 3 -8
Apple 19/09/2011 25 22
.
.
.
.
Orange 20/08/2011 9 0
Orange 27/08/2011 20 11
Orange 27/08/2011 7 -13
Orange 05/09/2011 15 8
Orange 12/09/2011 21 6
.
.
.
.
And also to count growth in count of fruits excluding negative values of differences-
Fruit Growth_In_Count
Apple 7
Orange 6.25
.
.
.

Thanks in advance.

aniketdixit, is this some sort of homework?

No sir. I am able to do that with floowing -

nawk '{c[$1]++;s[$1]+=$2}END{ for(i in c) printf("%s %.5f\n", i, s/c)}'

but thing is that it calculates differnce from top to bootom for particular thing. I need to do it in reverse. And also not able to exclude negative values.

Hi,

Anyway !!!
Try this below code.

awk '{if ( NR == 1 ){print $0,"0";}else{result=$3-prev;print $0,result;}if( result > 0 ){a[$1] = a[$1] + result;b[$1]=$1;c[$1]=c[$1]+1;}prev=$3;}END{for(i in a){v=a;d=c;res=v/d;print i,res;}}' Input_File

Cheers,
Ranga:)