Final answer:
To create a guessing game where the user will guess how many MMs there are in a jar, you can write a main method. Start by creating an ArrayList to represent the jar. Then, generate a random number between 1 and 5000 to determine the number of MMs in the jar. Add this many MMs to the ArrayList. To remove all the blue MMs from the jar, you can use a for loop to iterate through the ArrayList and check the color of each MM using the getColor() method. If the color is 'blue', remove the MM from the ArrayList using the remove() method. Finally, you can print out the original number of MMs in the jar using the size() method, the number of blue MMs removed from the jar using a counter variable, and the number of MMs remaining in the jar using the size() method again.
Step-by-step explanation:
To create a guessing game where the user will guess how many MMs there are in a jar, you can write a main method. Start by creating an ArrayList to represent the jar. Then, generate a random number between 1 and 5000 to determine the number of MMs in the jar. Add this many MMs to the ArrayList.
To remove all the blue MMs from the jar, you can use a for loop to iterate through the ArrayList and check the color of each MM using the getColor() method. If the color is 'blue', remove the MM from the ArrayList using the remove() method.
Finally, you can print out the original number of MMs in the jar using the size() method, the number of blue MMs removed from the jar using a counter variable, and the number of MMs remaining in the jar using the size() method again.