Using Scanner and Arrays import only
Requirements You will implement Nim in a Java program in which you play against the computer. You are free to choose the initial number of stones in each pile, or ask the user to enter one or more of these values. You should make the first move (i.e., the computer should never play first). On your turn, the program should print out the current state of the board and ask which pile you would like to remove stones from. For example (note that you must use the pile numbers 1, 2, and 3): Pile: 1 Stones: 3 2 4 3 5 Which pile would you like to remove stones from? If the pile number is not valid, the program should continue to ask for a number until a valid one is entered. The program should then ask how many stones you wish to remove from that pile. Suppose you choose to remove stones from pile 2: How many stones would you like to remove from pile 2? The program should remove the stones from that pile only if the pile has that many. If the number entered matches any of the following conditions, the program should continue to ask for a number of stones until a valid input is entered: the move would remove fewer than one stone the move would remove more stones than are available in the pile On the opponent's turn, the program should print the current state of the board, randomly generate selections for the opponent, and then report that to you. For example: Pile: 1 Stones: 1 2 4 3 5 The computer has taken 3 stones from pile 3. This process should repeat until only one stone remains in a single pile. The program should then report the final state of the board and whether or not you have won. For example: Pile: 1 Stones: 0 2 0 3 0 You won! Hints and lips Think about the big picture, then work your way to the specifics. What causes the game to end? After all, the game basically repeats itself in some pattern until a certain condition is met To create neat formatting for displaying the pile and the number of stones, you can use "t" (or tabbing) when printing to the console. O EX: System.out.println("Number of siblings:\t" + num; would result in Number of siblings: 2 If you want your program to slow down the printing done in the console, use Thread. sleep (numofSeconds at certain parts of your source code, where numOfSeconds is an int that represents the number of milliseconds the program should pause for. In order to use this, however, you need to make the main method look like this: public static void main(String[] args) throws InterruptedException