Question: Java Project Coding Name: LockerPuzzle.java Problem Description: A school has 100 lockers and 100 students. All lockers are closed on the first day of school.

Java Project

Coding Name: LockerPuzzle.java

Problem Description:

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 S1, opens every locker. Then the second student, S2, begins with the second locker, denoted L2, 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 L4 and changes every fourth locker. Student S5 starts with L5 and changes every fifth locker, and so on, until student S100 changes L100.

After all the students, have passed through the building and changed the lockers, which lockers are open? Write a program to find your answer.

(Hint: 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.)

The program should display the answer like this:

Sample Output:

Locker x is open

Locker y is open

Locker z is open

Project 2: (Pattern Recognition)Consecutive four equal numbers

Coding Name: PatterRecognition.java

Problem Description:

Write the following function that tests whether a two-dimensional list has four consecutive numbers of the same value, either horizontally, vertically, or diagonally.

public static boolean isConsecutiveFour(int[][] values)

Write a test program that prompts the user to enter the number of rows and columns of a two-dimensional list and then the values in the list and displays True if the list contains four consecutive numbers with the same value. Otherwise, display False. Here are some examples of the true cases:

Java Project Coding Name: LockerPuzzle.java Problem Description: A school has 100 lockers

Doc1.jpeg Compatibility Mode Saved to this PC Sign in -0 Insert Design Layout References Mailings Review View Help Tell me what you want to do Share File Home Cut Copy Replace Paste ,iti. Nor al TNo Spac, tending 1 Heading 2 Title Subtitle Subtle Em, Emphasis; Select Fonmat Painter Clipboard Font Paragraph Styles Editing 0 10 3 1 6 1 0 1 6 8 6 0 1 5 6 21829 5 521829 5 6 21629 9 6 2 18 29 6 5 611 91 65611 91 6 5 661 91 6 9 61191 13614 07 1 561407 1 361407 1 391407 3 3 3 3 4073 5 3 3 407 3 6 3 3 4073 3 3 9 4 0 7 0 1 0 3 1 6 1 0 1 6 86 0 1 0 1 0 3 1 6 1 0 168 6 0 1 0 1 0 3 1 6 1 0 168 6 0 1 Page 1 otl 0 words +100%

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!