Question: random group generator java description the application will ask how...
Random Group Generator Java
The application will ask how many groups are desired. User input is bolded.
Enter the number of groups: 3
When a valid integer is entered, the application will ask the user to enter a student name.
Enter the student name: Trudy Weigel
Assume that whatever the user types until they hit the enter key is a valid name. Keep entering names until an ‘x’ is entered.
Here's a sample:
Enter number of groups: 3
Enter the student name (or x to exit): Fred
Enter the student name (or x to exit): Barney
Enter the student name (or x to exit): Wilma
Enter the student name (or x to exit): Betty
Enter the student name (or x to exit): Bam Bam
Enter the student name (or x to exit): Pebbles
Enter the student name (or x to exit):
Enter the student name (or x to exit): x
The “x” concludes the list of student names.
Once the user has entered all of the names, the application will process the information and output the groups. Students should be randomly assigned to groups. (The shuffle method is very useful here!) The number of students per group should be maximized; however, it is possible that some groups will have one more student in the group than other groups. No student can be in more than one group. No student should be left out; every student should be in one group.
For example, I may ask for 3 groups from 11 students (that are entered from the console). The student’s names may be:
Your output must be formatted as below. The 3 groups might be:
You must use the Java classes ArrayList and Random to implement. In fact, you must use an ArrayList of ArrayLists. Also, all of the logic may not be contained in the main program. You must find a way to reuse code in this exercise. Therefore, the definition of another class is required with:
- a constructor
- at least one instance variable
- at least one method that returns a value
Name the program that contains the main method RandomGroupGenerator.java