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, 22.06.2019 11:00, Yamari000
What are two of the most common reasons that peolpe who need mental health care do not access it?
Answers: 1
image
Computers and Technology, 24.06.2019 00:40, ndurairajownkpq
What social factors affect your health
Answers: 3
image
Computers and Technology, 24.06.2019 04:30, shadenShaden2037
What is the process in which the software development team compiles information to determine the final product
Answers: 1
image
Computers and Technology, 25.06.2019 00:40, lexieprochaskaaa
Roger ginde is developing a program in supply chain management certification for managers. ginde has listed a number of activities that must be completed before a training program of this nature could be conducted. the activities, immediate predecessors, and times appear in the accompanying table: activity immediate predecessor(s) time (days) a -βˆ’ 44b -βˆ’ 55 c -βˆ’ 11 d b 1010 e a, d 55 f c 55 g e, f 1010 calculate the slack time. show the details.
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
English, 17.01.2021 03:10
Konu
Mathematics, 17.01.2021 03:10
Konu
Arts, 17.01.2021 03:10