Question: Please edit this code so it is separated into methods, the output in its own method and prompt for the number of lockers too instead

Please edit this code so it is separated into methods, the output in its own method and prompt for the number of lockers too instead of just it just being 100.
public class LockerPuzzle {
public static void main(String[] args){
boolean lock[]= new boolean[300];
for (int i =1; i < lock.length; i++){
lock[i]= false;
}
for (int i =1; i < lock.length; i++){
for (int j = i; j < lock.length; j++){
if ((j)%(i)==0){
lock[j]=!lock[j];
}
}
if (lock[i]== true){
System.out.println("Locker "+ i +" is open.");
}
}
}
}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!