MegaMan (megaman) wrote,
MegaMan
megaman

import tio.*;
import java.util.*;

class Birth2 {

public static void main(String[] args) {
Random random = initializePeople(args);
int trueTrials, numTrials, numSharing, maxPeople;
trueTrials = 0;
System.out.println("What is maxpeople:");
maxPeople = Console.in.readInt();
System.out.println("What is numSharing:");
numSharing = Console.in.readInt();
System.out.println("What is numTrials:");
numTrials = Console.in.readInt();
//trial(maxPeople, args);
System.out.println();
System.out.println( "That was hella rockin!");

for (int i = 1; i <= numTrials; i++) //this runs the trials
{
trueTrials = (trial(maxPeople, args, numSharing)) + trueTrials;
}

}



static int trial(int maxPeople, String[] args, int numSharing)
{
Random random = initializePeople(args);
int[] theYear = new int[365];
for(int mp = 0; mp < maxPeople; mp++)
{
int oneGuy = random.nextInt(365);
theYear[oneGuy] = theYear[oneGuy] + 1;
}

for(int i = 0; i < theYear.length; i++)
{
System.out.print( theYear[i]);
if (theYear[i] >= numSharing)
{
System.out.println();
System.out.println("greater than numSharing!");
return 1;
}
}

for(int i = 0; i < theYear.length; i++)
{
System.out.print( theYear[i]);
if (theYear[i] > 1)
{
System.out.println();
}
}
System.out.println("end of trial. fail.");
return 0;
}






static Random initializePeople(String[] args) {
if (args.length == 0) {
return new Random();
}
else {
return new Random(Integer.parseInt(args[0]));
}
}
}
Subscribe
  • Post a new comment

    Error

    Anonymous comments are disabled in this journal

    default userpic

    Your reply will be screened

    Your IP address will be recorded 

  • 2 comments