Question

Assume two boxes (box A and box B). Each contains zero or more pennies. What will be left in the boxes after the instructions below are executed if i) A contains 11 pennies, B contains 2 pennies ii) A contains 5 pennies, B contains 7 pennies if box A contains more than 6 pennies then while box A contains more pennies than box B do if box A contains more than 4 pennies then move 4 pennies from box A to box B else move 1 penny from box A to box B endif endwhile else move everything in box B to box A endif

0 0
Add a comment Improve this question Transcribed image text
Answer #1

[1] A-11 B-2
IF -True
While 11>2 True
     IF True A = 7 B = 6
While 7 > 6 True
     If True A = 3 B = 10
While 3 > 10 False
End While

After instruction :

Box A : 3
Box B : 10


-------------------------------------------------

[2] A-5 B-7
IF - False
Else -
   A = 12 B = 0

After instruction :

Box A : 12
Box B : 0

Add a comment
Know the answer?
Add Answer to:
Assume two boxes (box "A" and box "B"). Each contains zero or more pennies. What will...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT