mardi 20 janvier 2015

Count each occurrence of a random number

I'm not too good at Java (just started learning it recently). What i have is this method:



String gInfo(){
String[] Behavior = {"Sleeping", "Running home", "Studying", "playing pool", "walking to class"};
int rNum = (int) (Math.random() * Behavior.length);
return Behavior[rNum];


Basically what I'm trying to do is figure out how to calculate the number of times each array element occurs and turn it into a percentage.





Aucun commentaire:

Enregistrer un commentaire