[Solved] SOLVED: program that mimics a mailman

$25

File Name: SOLVED:_program_that_mimics_a_mailman.zip
File Size: 348.54 KB

SKU: [Solved] SOLVED: program that mimics a mailman Category: Tag:
5/5 - (1 vote)

write a program that mimics a mailman conducting an experiment in flipping mailboxes. A flip means opening a mailbox if it is closed, and closing a mailbox if it is open. There are 100 mailboxes numbered 1 to 100 that are all initially closed. In the first step, visiting every mailbox (i.e. mailboxes 1, 2, 3, , 100), he flips them all. Then in the second step, visiting every second mailbox (i.e. mailboxes 2, 4, 6, , 100), he flips them. Then in the third step, visiting every third mailbox (i.e. mailboxes 3, 6, 9, , 99), he flips them. In this manner he goes in steps of 4, 5, , 10,,50, and finally 100, wherein he directly goes to the 100th mailbox and flips it. At the end of this process, which mailboxes are open? Hint: Set up an array of Booleans all initialized to false representing closed mailboxes. Then, in steps of 1, 2, 3, , 100 go through the sequence of mailboxes and toggle them. In the end, print out the mailbox numbers that are open (have the value true).

5/5 – (5 votes)

Reviews

There are no reviews yet.

Only logged in customers who have purchased this product may leave a review.

Shopping Cart
[Solved] SOLVED: program that mimics a mailman
$25