/home/caleb/ASDV-Java/Assignments/MP5_CalebFontenot/src/main/java/com/calebfontenot/mp5_calebfontenot/MP5_CalebFontenot.java

    /*
     * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
     * Click nbfs://nbhost/SystemFileSystem/Templates/Project/Maven2/JavaApp/src/main/java/${packagePath}/${mainClassName}.java to edit this template
     */
    package com.calebfontenot.mp5_calebfontenot;

    import java.util.Scanner;

    /**
     *
     * @author caleb
     */
    public class MP5_CalebFontenot {
        // Toggles execution of the printArray method.
        static final boolean debug = false;

        public static void printArray(boolean[] array) {
            // Color codes
            final String ANSI_RED = "\u001B[31m";
            final String ANSI_GREEN = "\u001B[32m";
            final String ANSI_WHITE = "\u001B[37m";

            // Print the array
            for (int i = 0; i <= array.length - 1; i++) {
                if (array[i]) {
                    System.out.print(ANSI_GREEN + array[i] + " ");
                } else {
                    System.out.print(ANSI_RED + array[i] + " ");
                }
                if (i != 0) {
                    if ((i + 1) % 10 == 0) {
                        System.out.println(ANSI_WHITE);
                    }
                }
            }
        }

        public static void solveAndPrint(boolean[] array, int studentCount) {
            for (int student = 1; student <= studentCount; student++) {
                if (debug) {
                    System.out.println("Student " + student + " is interacting with the lockers!");
                }
                for (int i = 0; i <= array.length - 1; i++) {
                    if ((i + 1) % student == 0) {
                        array[i] = !array[i];
                    }
                }
                if (debug) {
                    printArray(array);
                }
            }
            for (int i = 0; i < array.length; i++) {
                if (array[i]) {
                    System.out.println("Locker " + (i + 1) + " is open.");
                }
            }
        }

        public static int menu() {
            // Create scanner
            Scanner input = new Scanner(System.in);
            int userInput;
            do {
                System.out.print("Enter 0 to quit, and 1 to enter the number of students: ");
                userInput = input.nextInt();
                if (userInput == 1) {
                    System.out.print("Enter the number of students: ");
                    userInput = input.nextInt();
                    break;
                }

            } while (userInput != 0);
            return userInput;
        }

        public static void main(String[] args) {
            final int N = menu();
            boolean[] lockers = new boolean[N];
            // Execute solve and print
            solveAndPrint(lockers, N);

        }
    }