add and subtract specific row using awk

Hi Folks
I have tried awk command to conditionally add or subtract value from specific row in a file. The test file looks like:

# cat test.txt
cont x y
Max 0.3 0.9
Min 0.2 0.9
diff 0.1 0
# awk '{for (i=2; i <=NF; i++) if ($i== "0") $i=$i+0.2; print}' test.txt

Output:

cont x y
Max 0.3 0.9
Min 0.2 0.9
diff 0.1 0.2

Desired Ouput:

cont x y
Max 0.5 1.1
Min 0.1 0.7
diff 0.4 0.4

That is when the diff is 0.1, than add the same column but first row (Max) by 0.2 and subtract same column but second row by 0.1, but when the diff is 0, than add the same column but first row value (Max) by 0.2 and subtract same column but second row by 0.2. AT the end the difference should be 0.4.
Any help will be great.

Bumping up posts or double posting is not permitted in these forums.

Please read the rules, which you agreed to when you registered, if you have not already done so.

You may receive an infraction for this. If so, don't worry, just try to follow the rules more carefully. The infraction will expire in the near future

Thank You.

The UNIX and Linux Forums.

(See original here.)