Four int variables , x1, x2, y1, and y2, have been declared and been given values. Write an expression whose value is the difference between the larger of x1 and x2 and the smaller of y1 and y2.

Four int variables , x1, x2, y1, and y2, have been declared and been given values. Write an expression whose value is the difference between the larger of x1 and x2 and the smaller of y1 and y2.

LANGUAGE: JAVA

CHALLENGE:

Four int variables , x1, x2, y1, and y2, have been declared and been given values. Write an expression whose value is the difference between the larger of x1 and x2 and the smaller of y1 and y2.

SOLUTION:

(x1 < x2 ? x2 : x1) - (y1 < y2 ? y1 : y2)

Add comment