Since opposite sides of rectangle are equal, We can say that:
x + y = 12 ----- (i)
x - y = 8 ------ (ii)
We get 2 simultaneous equations. We can add (i), (ii)
x + y = 12
+ (x - y = 8)
-----------------
2x = 20, x = 20/2=10
Substitute x in (ii)
10 - y = 8
y = 10 - 8 = 2
So x = 10, y = 2