Question
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
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started