Name: 4. (20 pts) Given 3 integers r, 3, and :, write the condition part of an i
ID: 3587229 • Letter: N
Question
Name: 4. (20 pts) Given 3 integers r, 3, and :, write the condition part of an if statement to test the following. You need to use the boolean operators AND and OR, as well as comparison oper- ators like LESS THAN and EQUAL TO, in the conditions. Your condition shoulk to true when the following are satisfied and it should evaluate to false when the following are not satisfied. (a) All the three numbers r, v, and : are equal to each other. (b) Two of the numbers are equal and third number is different. Hint: Your condition should work for all 3 possible permutations. (c) All three numbers are different from each other and less than or equal to 50.Explanation / Answer
a)
if(x == y && y == z)
return true;
else
return false;
b)
if((x == y && y!=z) && (x == z && z!=y ) && (y == z && y!=x))
return true;
else
return false;
c)
if((x !=y ) && (y != z) && (z != x) && x <= 50 && y <= 50 && z <= 50)
return true;
else
return false;
**Comment for any further queries. Upvote if the answer is satisfactory.
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.