Question
Random Group Generator Java Description: The application will ask how many groups are desired. User inputis bolded. Enter the number of groups: 3 When a
Random Group Generator Java
Description:
The application will ask how many groups are desired. User inputis bolded.
Enter the number of groups: 3
When a valid integer is entered, the application will ask theuser to enter a student name.
Enter the student name: Trudy Weigel
Assume that whatever the user types until they hit the enter keyis 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):Dino
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 willprocess the information and output the groups. Students should berandomly assigned to groups. (The shuffle method is very usefulhere!) The number of students per group should be maximized;however, it is possible that some groups will have one more studentin the group than other groups. No student can be in more than onegroup. No student should be left out; every student should be inone group.
For example, I may ask for 3 groups from 11 students (that areentered from the console). The student’s names may be:
Trudy Weigel
Jim Dangle
Jonesy
Raineesha Williams
Clementine Johnson
Junior
James Garcia
C. Kimball
Frank Rizzo
Jack Declan
Mayor Hernandez
Your output must be formatted as below. The 3groups might be:
Group #1
Jack Declan
Jim Dangle
Mayor Hernandez
Raineesha Williams
Group #2
C. Kimball
Trudy Weigel
Clementine Johnson
Junior
Group #3
Jonesy
Frank Rizzo
James Garcia
You must use the Java classes ArrayList andRandom to implement. In fact, you must use anArrayList of ArrayLists. Also, all of thelogic may not be contained in the main program. You must find a wayto reuse code in this exercise. Therefore, the definition ofanother 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 methodRandomGroupGenerator.java
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access with AI-Powered Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started