Consider the following scenario:A high school has 1000 students and 1000 lockers, one locker for each student. On the first day of school, the principal plays the following game: She asks the first student to open all the lockers. She then asks the second student to close all the even-numbered lockers. The third student is asked to check every third locker. If it is open, the student closes it; if it is closed, thestudent opens it. The fourth student is asked to check every fourth locker. If it is open, the student closes it; if it is closed, the student opens it. The remaining students continue this game. In general, the nth student checks every nth locker. If it is open, the student closes it; if it is closed, the student opens it. After all the students have taken turns, some of the lockers are open and some are closed.The program see in the photo, when ran, should ask the user to enter the number of lockers in the school. The program will output the number of lockers and the locker numbers of the ones that are open. The statements are in the wrong order, and there are some bugs in the program. Rearrange the statements (do not add other lines of code), find and remove the bugs so that theprogram can run properly. RENAME THE CLASS TO“LASTNAME_CLASSCODE_LOCKER”.
Extracted text: import java.util.Random; public class Locker{ public static void main(String[] args){ Scanner keyboard = new Scanner(System.in); int studentvisitCount = 0; System.out.print("Enter the number of lockers: "); int numberofLockers = console.nextInt(); for(int x=0; x<=number0flockers; x++){="" if(x%y="=0){" studentvisitcount--;="" }="" for="" (int="" y="0;">=number0flockers;><=x; y++){ if(studentvisitcount%3!=0){ system.out.print (y+" "); } } } system.out.println("the number of lockers and students are: "+number0f lockers); system.out.print("the locker numbers left open at the end of the game are: "); } } y++){="" if(studentvisitcount%3!="0){" system.out.print="" (y+"="" ");="" }="" }="" }="" system.out.println("the="" number="" of="" lockers="" and="" students="" are:="" "+number0f="" lockers);="" system.out.print("the="" locker="" numbers="" left="" open="" at="" the="" end="" of="" the="" game="" are:="" ");="" }="">=x; y++){ if(studentvisitcount%3!=0){ system.out.print (y+" "); } } } system.out.println("the number of lockers and students are: "+number0f lockers); system.out.print("the locker numbers left open at the end of the game are: "); } }>
Already registered? Login
Not Account? Sign up
Enter your email address to reset your password
Back to Login? Click here