unreacheable statement error
I'm new to Java. honestly most of the time i have no idea what i'm doing. I'm suppose to do a prog. about dice throwing simulation. I'm getting the following errors that i do not understand:
DiceSimulation232.java:59: unreachable statement DiceSimulation232 DiceSimulation232 = new DiceSimulation232();
and
DiceSimulation232.java:91: missing return statement
}
^
below is my prog. any help will be appreciated.
import java.io.PrintStream.*;
import java.util.Scanner;
import java.io.*;
public class DiceSimulation232
{
static final int NUMBER_OF_ROLLS = 10000;
public static void main(String[] args)
{
double average;
System.out.println("Total On DiceAverage Number of Rolls");
System.out.println("---");
for ( int dice = 2; dice <= 12; dice++ )
{
average = getAverageRollCount( dice );
System.out.println(dice + " " + 10);
System.out.println("");
System.out.println(average);
}
}
static double getAverageRollCount( int roll )
{
int rollCountThisExperiment;
int rollTotal;
double averageRollCount;
rollTotal = 0;
for ( int i = 0; i < NUMBER_OF_ROLLS; i++ ) {
rollCountThisExperiment = rollFor( roll );
rollTotal += rollCountThisExperiment;
}
averageRollCount = ((double)rollTotal) / NUMBER_OF_ROLLS;
return averageRollCount;
}
static int rollFor( int N )
{
int die1, die2;
int roll;
int rollCt;
rollCt = 0;
boolean done = false;
do {
die1 = (int)(Math.random()*6) + 1;
die2 = (int)(Math.random()*6) + 1;
roll = die1 + die2;
rollCt++;
} while ( roll != N );
return rollCt;
DiceSimulation232 DiceSimulation232 = new DiceSimulation232();
System.out.println("Dice throwing simulation");
do
{
System.out.println("Options: (n)ew simulation, (a)dditional rolls," +
" (p)rint report, (q)uit");
System.out.print("Enter n, a, p, or q ==> ");
char choice;
Scanner keyboard = new Scanner(System.in);
choice = keyboard.next().charAt(0);
switch (choice)
{
case 'n': case 'N':
System.out.println("newSimulation");
break;
case 'a': case 'A':
System.out.println("additionalRolls");
break;
case 'p': case 'P':
System.out.println("printReport");
break;
case 'q': case 'Q':
done = true;
break;
default:
System.out.println("Invalid selection.");
} // end switch
} while (!done);
}
} // end DiceSumulation232
thanks

