1. Engineering
  2. Computer Science
  3. random group generator java description the application will ask how...

Question: random group generator java description the application will ask how...

Question details

Random Group Generator Java

Description:

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): 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 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:

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 3 groups 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 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:

  1. a constructor
  2. at least one instance variable
  3. at least one method that returns a value

Name the program that contains the main method RandomGroupGenerator.java

Solution by an expert tutor
Blurred Solution
This question has been solved
Subscribe to see this solution