Average of numbers in output.

I have written this code

Code:

for (int rolls = 0; rolls < 30; rolls++) {

int value = (int)(Math.random() * 6 + 1);

System.out.print(value + " ");

And it produces this output: 5 3 4 6 4 2 2 2 5 2 3 3 1 2 3 5 3 1 1 6 1 1 6 1 3 4 6 6 5 3

Now I need to find the average of my 30 dicerolls, and print that out aswell. Can anyone help me? :(hi):

Thanks in advance.

Re: Average of numbers in output.

Start with defining for yourself in plain English how you calculate the average mathematically without any code, then translating that to Java code should be trivial.

Re: Average of numbers in output.

pseudo code is a great place to start, but when translating don't forget about the scope of your variables

Scope tutorial

Re: Average of numbers in output.

Uh, you're linking to the JNDI tutorial here. That ain't exactly the best read for a novice :)

Re: Average of numbers in output.

whoops still had the other one in the clip board! thanks

Re: Average of numbers in output.

Don't like that new link very much to be honest, but perhaps it is helpful.

Re: Average of numbers in output.

Thank you for all the tips's's's. I've finished my task now :)