Computers and Technology
Computers and Technology, 07.05.2021 20:50, ella3714

A custodial staff person at the College does a peculiar thing at night. There is a corridor with a number of lights controlled by toggle switches. Initially all lights are off. Pressing the switch on a light will turn it on. Pressing it again will turn it off. This staff member walks down a corridor with n light n times. On the ith trip the person only toggles the switches whose position number is divisible by i. When coming back to the initial position, the person does not press any switches. Write a program that determines the state (on or off) of the last light in the corridor after the staff member has made n trips up and down the corridor doing this routine Your program should prompt the user for the number of lights in the corridor, read the number and determine and print the value of the last light. You should print an error message if the user does not enter a positive integer. Use a loop for multiple inputs. The loop should terminate when the user enters 0 for the number of lights. Possible sample output: Please enter a positive integer. -3 This is not a positive integer. Please try again. Please enter a positive integer. 3 The last bulb is off. Please enter a positive integer. 0 Have a nice day.

answer
Answers: 1

Other questions on the subject: Computers and Technology

image
Computers and Technology, 24.06.2019 10:00, lashaunahard
Each time you save a document, you will need to type in the file type in which it should be saved you can select the save button to save it with the same file name if it has been previously saved you will need to select the location to save the file you will need to use the save as dialog box
Answers: 1
image
Computers and Technology, 24.06.2019 15:30, jhony70
What type of forensic evidence was recovered during the bomb set off at the new mexico facility on the video that was similar to the evidence obtained at the boston bombings and how did the evidence allow the researchers to connect other pieces of evidence to the same bomb?
Answers: 2
image
Computers and Technology, 25.06.2019 16:00, elijahedgar876
What are the two parts of an event? a. the object and the property b. the icon and the tooltip c. the frame and the coordinate d. the condition and the action
Answers: 1
image
Computers and Technology, 25.06.2019 21:30, domie5910
What is an example of the personal information that an identity thief would look for
Answers: 2
Do you know the correct answer?
A custodial staff person at the College does a peculiar thing at night. There is a corridor with a n...

Questions in other subjects:

Konu
Mathematics, 13.09.2021 09:50
Konu
Mathematics, 13.09.2021 09:50