Welcome, guest! Login / Register - Why register?
Psst.. new poll here.
Psst.. new forums here.
Microsoft is blocking us again (TY IP Reputation!) so just use oauth login instead. :)

Paste

Pasted as JavaScript by lmurph ( 5 years ago )
/**
 * Write a description of your class here.
 * 
 */

import java.util.Scanner;

public class RandomOrder
{
    public static void main(String[] args)
    {
        Scanner in = new Scanner(System.in);
        System.out.println("How many participants do you have?");
        int rosterSize = in.nextInt(); 

        String [] roster = new String[rosterSize];
        String word = in.nextLine();
        
        for(int i = 0; i < rosterSize; i++)
        {
            System.out.println("Enter name " + (i + 1));
            roster[i] = in.nextLine();
        }

        int random = 0;
        int numDone = 0;
        while (numDone < rosterSize) 
        {
            random = (int) (Math.random() * rosterSize);
            if(! roster[random].equals(""))
            {
                System.out.println(roster[random]);
                roster[random] = "";
                numDone++;
            }
        }
    }
}

 

Revise this Paste

Parent: 114739
Your Name: Code Language: