In this question you should be clear with one concept of Goodwill valuation… Whenever goodwill is valued, all abnormal gains and all abnormal losses are removed from the profits earned in that year. Abnormal items are those which don’t occur in a normal course of business like here its inclusion of defective items in closing stocks. Other examples could be over valuation/ undervaluation of stocks..
Now coming to question-
Firstly you remove abnormal gain of INR 2200 from the profits of 1999-2000.. why?? See when any abnormal items is there in closing stock of 1999-2000, here its INR 2200 which means your profit have gone up by 2200 because of inclusion in closing stock(it appears on Cr. Side of trading A/c) . So when there is abnormal increase on Cr. Side of statement it gets reflected in profit by moving it up.
Now profit (1999-2000) for goodwill valuation will be 26100 – 2200 = INR 23900
Come to profit of 2000-2001 which is INR31200. In this there will be abnormal opening stock of INR 2200 and abnormal closing stock of INR 6200. Now we have to remove both of these abnormalities because it gets reflected in profit.. So firstly add abnormal opening stock of 2200 to INR 31200 why?? When there is any abnormality on Dr. side of statement it will reduce the profit abnormally, so add back 2200 to 31200. Then you will get INR 33400…. Now deduct abnormal closing stock of 6200 from 33400, you will get profit as INR27200.
Now in your hand there are profits for 3 yrs (as per goodwill valuation)
Calculate Avg. Profit = 2000 + 23900 + 27200/3
= INR 17700
Goodwill = Avg. profit * No. of years of purchase
= 17700 * 1
= INR 17700
NOTE --- Assume no. of years of purchase as 1year as question is silent about it.