Question: Consider the following method, which is intended to return the product of 3 and the nonnegative difference between two int parameters. public int threeTimesDiff(int num1,

Consider the following method, which is intended to return the product of 3 and the nonnegative difference between two int parameters.

public int threeTimesDiff(int num1, int num2) { return 3 * (num1 - num2); }

Which precondition is required so that the method works as intended for all values of the parameters that satisfy the precondition?

  • num1 > 0, num2 > 0

  • num1 >= 0, num2 >= 0

  • num1 >= num2

  • num2 >= num1

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!