?

Log in

No account? Create an account
 
 
18 May 2004 @ 11:30 am
 
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]));
}
}
}
 
 
 
Siner Dsirnerd on May 18th, 2004 12:42 pm (UTC)
are you taking a Java class, or just playing around with java. I sort of want to write a program for my phone, but I'm not sure exactly how it works. If i had time that i didn't want to spend doing something else, I guess i would research that and write a program for my phone, like a video game or something, but i don't really want to do it.
MegaManmegaman on May 18th, 2004 12:52 pm (UTC)
fun with school.
I'm actually taking a java class. It's fun but I don't have too much time for it. posting the code in my journal is the easiest way to get it from the stupid Solaris computers to me, and then access it again later. Java is fun but I spent hella long trying to make the teachers stupid mandatory element that he wrote work.