I am back again a few days older and hopefully a little wiser.

Today I found a new error that I have not encountered before and It has me puzzled.

For background, this is what I am trying to achieve and the perimeters set.

• Use (int) ( Math.random () * 6) +1; to make a dice game.

• Have the program calculate the result several thousand times.

• Calculate the average of all the throws.

• Declare the median of all the throws

• Calculate how many times each result happens.

• Have the results print.

Amount of throws:

Average: x.x

Median: x.x

Amount of throws giving:

1 2 3 4 5 6

X x x x x x

• To get the average we take all the throws and combine them, take that sum and divide with the number of throws. Remember to use x.0 amount of throws to avoid loss.

• The median is decided by sorting the numbers and taking the number that is in the middle. (size-1)/2 (only works of the number of throws is un-even), or taking the two numbers in the middle and adding them together and dividing the result in 2.

• To sort the values, use Arrays.sort.

• Save the results in an array with 6 elements (0-5) with the different sides of a die, that gets increased by 1 every time the number gets thrown.

• Switch/case to filter the throws.

This is my code so far:

public class Lab5_4 { public static void main(String[] args){ //creat the Array int size =6; int[] intArray; intArray =new int[size]; for (int i=0; i<size; i++){ intArray[i] =i; } // creat the code for the dice game and the switch for (int step=0; step <=5000; step++){ int throw =(Math.random () * 6) + 1; switch (throw){ case 1: intArray[0]++; case 2: intArray[1]++; case 3: intArray[2]++; case 4: intArray[3]++; case 5: intArray[4]++; case 6: intArray[5]++; } } system.out.println(intArray.charAt[0]); } }

It is primarily the Error: not a statement I would like help with.

What I wanted my code to do was to calculate the throw 5000 times and sort the results into the appropriate array spaces.

I do not believe my code does this currently. I can't think of a way to implement the step without multiplying it with the throw result. I figure a way around this would be to have it multiply by the step and then divide the answer to get the original throw but it does seem like a roundabout way of doing things. Tips on a more simple way would be appreciated.

As I evidently failed at posting the image here is a link to the pasteboard with the error image Link to error