Code help! thanks


I'm new to java, I'm taking a class now but I'm totally lost in the class.. I'm really struggling.. and am in seek of some assistance.. The teacher has assigned a project and I do not know where to start.. I'm new to this forum so please forgive me if I break any rules for posting..

Any ways the project that was assigned to me is due tommorrow.. and I forgot about it till now..So any help would be greatly appricated...

Heres the project:

simulating throwing a die and counts the frequency of each possible outcome: 1 though 6...and also compute the ratio of each outcome occurrences divided by the total of throwings

Again thanks for your help !
Who is Participating?
derkecConnect With a Mentor Commented:
Let us know where you get stuck. It's going to look something like:


int numberToThrow = 100;
Random rand = new Random();
int[] count = {0,0,0,0,0,0};

for(int i = 0; i < numberToThrow; i++) {
    nextRoll = rand.nextInt[6]; // number 0-5 which we pretend is 1-6
System.out.println("Number of times 1 was thrown: " + count[0]);
System.out.println("Number of times 2 was thrown: " + count[1]);
System.out.println("Percentage of times 1 was thrown: " + count[0]/numberToThrow);

I'm sure nobody here wants to give too much away since this is a homework problem, but I imagine you know that you will need to simulate the die throw by generating some random numbers, and collect some statistics on the outcomes. Look at java.util.Random to start, and its nextInt(int n) method.
aCCeSSgRanteDAuthor Commented:
Actually, I was looking into this for a friend.. he was on a deadline and ask if I could help him.  Unfortunately, I dont do any programming with java.  I was looking ay maybe getting some code to help him get started..

Thanks for your suggestion.. and I will pass on the things you ask for him to check..

aCCeSSgRanteDAuthor Commented:
If anyone has the time..

the assignment is posted..



ps.. I'm no person to ask for a handout but my forte is not java..

thanks again for anyhelp
aCCeSSgRanteDAuthor Commented:
I dont know if this helped my friend out or not.. but I gave it to him.. and havent heard of him .. soo i guess it works..

anyhoot.. thanks for the help..

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.