What precondition (P) must exist in order to satisfy the given post...

Question

What precondition (P) must exist in order to satisfy the given postcondition (Q) for the following code segment? Show all work and provide explanations for all assumptions, adjustments, and/or implications.

P={?}
Y=W-2;
X=2Y+1;
If X>0
Z=3X;
Else
Z=2X +Y;
Do while Z>0
Z=Z – 1;
Enddo;
Q = {X=1,Z=0}

Solution Preview

These solutions may offer step-by-step problem-solving explanations or good writing examples that include modern styles of formatting and construction of bibliographies out of text citations and references. Students may use these solutions for personal skill-building and practice. Unethical use is strictly forbidden.

P={?} (1)
Y=W-2 (2)
X=2Y+1 (3)
IF X>0 Z=3X; (4)
Else Z=2X+Y; (5)
Do while Z>0
Z=Z-1;
Enddo; (6)
Q={X=1,Z=0} (7)

For easier tracking of the code I have counted each instruction and condition.

Precondition refers the value of P that determines the final values for X and Z from the post-condition (after steps 2, 3, 4/5 and 6 were performed).

The provided output (X=1 and Z=0) is possible only for specific value of P; this is why it is needed to find out that value....

By purchasing this solution you'll be able to access the following files:
Solution.docx.

50% discount

Hours
Minutes
Seconds
\$5.00 \$2.50
for this solution

or FREE if you
register a new account!

PayPal, G Pay, ApplePay, Amazon Pay, and all major credit cards accepted.

Find A Tutor

View available Computer Science - Other Tutors

Get College Homework Help.

Are you sure you don't want to upload any files?

Fast tutor response requires as much info as possible.