Gain of $7150
Cost of item $42,200 less residual value of $5,500 equals $36,700 of an asset that will be depreciated over 4 years.
Depreciation/year is $36,700/4 or $9,175/year.
Basis after two years would be $42,200 minus 2 times $9, 175 which equals $23,850.
Sales price: $31,000 less basis of $23,850 equals a GAIN of $7,150.
Note this is a Financial Accounting problem, not a tax accounting problem.