This program is a game that requires an input for a n lockers. After the input t
ID: 3624118 • Letter: T
Question
This program is a game that requires an input for a n lockers.
After the input the first sudent will open the lockers.
Then the second student will close all the even-numberd lockers.
Then the third student will chek every third locker
if it's open it will close if it's closed it will open it.
So every (n)-th student will check (n)-th locker and close
it if it's open and open if its closed.
When this program is over, it should print the total lockers
that are open and the number of the lockers that are open.
There is a hint:
the outside for loop will loop thru the number of lockers that are in the game ...
the inner for loop will be used to determine (count) the number of divisors (or factors) of each locker one at a time.
The number of factors your find (even vs. odd) will determine if the locker is open or closed.
Even numbers are closed
odd numbers are open.
Input: The number of lockers.
Output: The total lockers that are open.
The number of the lockers that are open.
Explanation / Answer
I'm not sure if you the mathematically derived result, or you want the program to blindly do it for you.. Here's the program that will implement your question anyway: void main(int n) { int[] arr=new int[n]; int k=1; for(int x=0;xRelated Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.