Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

LAB Lights in the Hallway Situation: You are standing at the start of a very long hallway, longer than the eye can see. Along the

LAB Lights in the Hallway Situation: You are standing at the start of a very long hallway, longer than the eye can see. Along the midline of its ceiling are light fixtures, spaced one foot apart, with a string that hangs from each fixture. A pull of the string will turn the bulb on, with another pull turning the bulb off. a student begins walking down the hall and pulls every single string (1, 2, 3), turning all the light bulbs on. A second student begins walking down the hall and pulls every second string (2, 4, 6) thereby turning each of these lights off. Then a third student follows the other two, pulling every third string (3, 6, 9) thereby turning some lights on and some others off. A fourth student follows pulling every fourth string and so on FOREVER! Well, not quite forever but for a long time with many students and lots of pulling of strings. Of the first 100 light bulbs, which ones are on?

The Lab: You will create two classes LightBulb and LightDriver. You are to write the program to simulate the situation as described above, but without the FOREVER part.After the students move down the hall pulling strings, have the program count the number of light bulbs that are burning. Your first step is to run the simulation with 100 bulbs in the hall and 20 students pulling the strings. Your next step will be to run with a random number of bulbs in the hall (between 100 and 1,500) and a random number of students (between 10 and 150).

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

More Books

Students also viewed these Databases questions

Question

8. Explain the relationship between communication and context.

Answered: 1 week ago