Question: Please write Java program with comments that print as below Part 1 - Locker Puzzle A school has 100 lockers and 100 students. All lockers

Please write Java program with comments that print as below  Please write Java program with comments that print as below Part

Part 1 - Locker Puzzle A school has 100 lockers and 100 students. All lockers are closed on the first day of school. As the students enter, the first student denoted as S,, opens every locker. Then the second student, S2, begins with the second locker, denoted as La, and closes every other locker. Student S3 begins with the third locker and changes every third locker (closes it if it was open and opens it if it was closed). Student S4 begins with locker L, and changes every fourth locker. Student Ss starts with locker L, and changes every fifth locker, and so on, until student Soo changes L00- After all the students have passed through the building and changed the lockers, which lockers are open? Write a program named LockerPuzzle.java to find your answer and display all open locker numbers separated by exactly one space. . Your program must use an array of 100 boolean elements, each of which indicates whether a locker is open ( true) or closed (false). Initially, all lockers are closed . You do not need to write a special case for students S, and S2 Student S, is changing the status of every locker starting with L, and S2 is changing the status of every second locker starting with L2 Part 2 - Merge Two Sorted Lists Write a method that merges two sorted lists of integers into a new sorted list: public static int[1 nergelint [1 listl, int I1 List2) Implement the method in a way that takes at most list 1Length + list2. length comparisons. See this website e for an animation of the implementation. Write a test program named MergeTest.java that prompts the user for the lengths and contents of two sorted lists. Here is a sample run, with user input shown in bold Enter size of list 1: 5 Enter itens in list 1: 1 5 16 91 248 Enter size of list 2: 4 Enter itens in list 2: 2 45 27 listi is 1 5 16 91 248 list2 is 24 5 27 The nerged list is 1 2455 16 27 91 248

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 Databases Questions!