Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Part I: Comparison Function Java based program that given two actions and a prin

ID: 3542986 • Letter: P

Question

Part I: Comparison Function

Java based program that given two actions and a principle, return True if the first action is preferable, according to the principle, to the second action, else return False.


Algorithm

Input:

Output: True/False

Process:

Test Data


Case 1

Exchanging the order of the actions should result in True.



Run


PosCase = (2 2 -1) - (-2 -2 2) = (4 4 -3)

NegCase = (-2 -2 2) - (2 2 -1) = (-4 -4 3)

PosCase not greater than or equal to any list of Principle because of the -3

and NegCase is greater than or equal to third list of Principle

Therefore the condition specified in step number 4 is satisfied and the function should return False

If the actions are reversed so are the cases:

PosCase = (-4 -4 3)

NegCase = (4 4 -3)

and the PosCase is greater than or equal to the third list of Principle

while the NegCase is not greater than or equal to any list of the Principle

so the condition specified in step 2 is satisfied and the function should return True


Case 2

Case 3

Case 4

Case 5

Case 6

Case 7


Explanation / Answer


Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote