Given pre-condition: x = v1, y = v2 What statements must be executed for the pos
ID: 3768445 • Letter: G
Question
Given pre-condition: x = v1, y = v2
What statements must be executed for the post-condition, z = max(abs(v1), abs(v2))?
1:
// Pre-condition: x = v1, y = v2
x1 = Math.abs(x);
y1 = Math.abs(y);
if (x1 > y1) return x1; else return y1;
2:
// Pre-condition: x = v1, y = v2
if (x > y) return x; else return y;
3:
// Pre-condition: x = v1, y = v2
if (x > y) return Math.abs.(x) ; else return Math.abs(y);
4:
// Pre-condition: x = v1, y = v2
x1 = Math.abs(x);
y1 = Math.abs(y);
if (y1 > x1) return x1; else return y1;
// Pre-condition: x = v1, y = v2
x1 = Math.abs(x);
y1 = Math.abs(y);
if (x1 > y1) return x1; else return y1;
Explanation / Answer
// Pre-condition: x = v1, y = v2
x1 = Math.abs(x);
y1 = Math.abs(y);
if (x1 > y1) return x1; else return y1;
These statements must be executed.
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.