Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Translate each of the following English statements into logical tests that could be used in an if/else statement. Write the appropriate logical test for each

image text in transcribedimage text in transcribed

Translate each of the following English statements into logical tests that could be used in an if/else statement. Write the appropriate logical test for each statement below. Assume that three int variables, x, y, and z, have already been declared. (Note: This problem is currently not very well implemented in Practice-It. Right now our system is just checking whether your answer exactly matches our expected answer, but some other correct answers might be marked as incorrect even though they would work. We plan to improve the system in the future. Sorry for the inconvenience.) a. Z is odd. z % 2 != 0; Sound FIX 2 ; 1. Z is not greater than y's square root. c. y is positive 3. Either x or y is even, and the other is odd. (Hint: Don't use B & or ||.) ey is a multiple of z z is not zero x % 2 != y % 2; y % z == 0; z != 0; Math.abs(y) > Math.abs(z) (x >= 0) == (z = ; 0; result: pass question #4: d. Either x or y is even, and the other is odd. (Hint: Don't use && or ||.) your answer: x % 2 != y % 2; result: pass question #5: e. y is a multiple of z. your answer: y % z == 0; result: pass question #6: your answer: result: f. z is not zero. z != 0; pass question #7: g. y is greater in magnitude than z. your answer: Math.abs(y) > Math.abs(z) result: pass question #8: h. x and z are of opposite signs. your answer: (x >= 0) == (z = 0; result: pass question #11: k. x is even your answer: x % 2 == 0; result: pass question #12: I. x is closer in value to y than z is. your answer: Math.abs(x - y) ; 1. Z is not greater than y's square root. c. y is positive 3. Either x or y is even, and the other is odd. (Hint: Don't use B & or ||.) ey is a multiple of z z is not zero x % 2 != y % 2; y % z == 0; z != 0; Math.abs(y) > Math.abs(z) (x >= 0) == (z = ; 0; result: pass question #4: d. Either x or y is even, and the other is odd. (Hint: Don't use && or ||.) your answer: x % 2 != y % 2; result: pass question #5: e. y is a multiple of z. your answer: y % z == 0; result: pass question #6: your answer: result: f. z is not zero. z != 0; pass question #7: g. y is greater in magnitude than z. your answer: Math.abs(y) > Math.abs(z) result: pass question #8: h. x and z are of opposite signs. your answer: (x >= 0) == (z = 0; result: pass question #11: k. x is even your answer: x % 2 == 0; result: pass question #12: I. x is closer in value to y than z is. your answer: Math.abs(x - y)

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Data Management Databases And Organizations

Authors: Richard T. Watson

6th Edition

1943153035, 978-1943153039

More Books

Students also viewed these Databases questions