Question: I have some code and I am not getting the results I want, can someone check this over and make sure that its correct and
I have some code and I am not getting the results I want, can someone check this over and make sure that its correct and that its printing out the right results. Thank you, and will thumbs up.


here is the code:
import java.util.Random;
public class Darts {
public static void main(String[] args) {
// double type variables for different counter
double bullsEyeCounter = 0, yellowCounter = 0, blueCounter = 0;
double redCounter = 10, gameCounter = 0, scoreCounter = 0,
whiteCounter = 0, miss = 0;
double totalMeanScore = 0, meanScore = 0;
// loop to perform 5 iterations
for (int i = 0; i
{
gameCounter++;
// double type variables for meanscore
for (int dart = 1; dart
{
// call Math.random function to generate random value for x and y
double dartx = 6 * Math.random();
double darty = 6 * Math.random();
double dartxy = (dartx * dartx) + (darty * darty);
// checking area/hit dart board
// bullseye
if ( dartxy
{
bullsEyeCounter++;
scoreCounter += 50;
}
else if (dartxy
{
yellowCounter++;
scoreCounter += 25;
}
else if (dartxy
{
blueCounter++;
scoreCounter += 15;
}
else if (dartxy
{
redCounter++;
scoreCounter += 10;
}
else if (dartxy
{
whiteCounter++;
scoreCounter += 5;
}
// dart misses the board
else
{
miss += 1;
}
}
// mean score for 5 darts
meanScore = scoreCounter / 5;
// reset scoreCounter
scoreCounter = 0;
totalMeanScore = totalMeanScore + meanScore;
}
// print output
System.out.println("Meanscore for 5 darts = " + totalMeanScore/gameCounter);
System.out.println("Expected value for Bullseye = " +
(50 * bullsEyeCounter) / (5 * gameCounter));
System.out.println("Expected value for Yellow = " +
(25 * yellowCounter) / (5 * gameCounter));
System.out.println("Expected value for Blue = " +
(15 * blueCounter) / (5 * gameCounter));
System.out.println("Expected Value for Red = " +
(10 * redCounter) / (5 * gameCounter));
System.out.println("Expected value for White = " +
(5 * whiteCounter) / (5 * gameCounter));
}
}
Darts Construct and perform a Monte Carlo simulation of a darts game. The rules are Dart board area Points Bullseye Yellow ring Blue ring Red ring White ring 50 25 15 10 From the origin (the center of the bullseye), the radius of each ring is as follows Distance to outer ring edge from the origin (in.) Ring Thickness (in.) Bullseye Yellow Blue Red White 1.0 1.5 2.5 3.0 4.0 2.5 5.0 8.0 12.0 The board has a radius of 1 ft (12 in.). Darts Construct and perform a Monte Carlo simulation of a darts game. The rules are Dart board area Points Bullseye Yellow ring Blue ring Red ring White ring 50 25 15 10 From the origin (the center of the bullseye), the radius of each ring is as follows Distance to outer ring edge from the origin (in.) Ring Thickness (in.) Bullseye Yellow Blue Red White 1.0 1.5 2.5 3.0 4.0 2.5 5.0 8.0 12.0 The board has a radius of 1 ft (12 in.)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
