I am having a little trouble with my program, I am supposed to estimate pi through a series of trials of throwing darts at a circular board of radius 1. Where I run into trouble is when I try to compile it comes up with the error "cannot find symbol - variable X". I don't really know why this is happening, I know that this error occurs when things are misspelled, but I know I did not misspell X. If you can help I would appreciate it very much!
/**
* The purpose of this program is to calculate pi by throwing darts
*
*
*
*/
import java.util.Scanner;
public class Darts
{
//create an array length number of darts for x and y
//method to generate random numbers
//calc pi = 4 hits / attempts
//method to print
public static int dartHit (double X, double Y, int hit)
{
X = Math.random();
Y = Math.random();
hit = 0;
if ( Math.pow(X, 2) + Math.pow(Y, 2) <= 1)
{
hit++;
}
return hit;
}
public static double calcPi (int hit, int attempts, double pi)
{
pi = 4 * ((hit * 1.00) / (attempts * 1.00));
return pi;
}
public static void main(String[ ] args)
{
Scanner in = new Scanner(System.in);
System.out.println("How many darts per trial? ");
int attempts = in.nextInt(); //(N)
System.out.println("How many trials?");
int trials = in.nextInt();
double [] pies = new double [trials];
double sum = 0.0;
for (int j = 0; j < trials; j++)
{
for ( int i = 0; i < attempts; i++)
{
int dartHit = dartHit (X, Y, hit);
double calcPi = calcPi(hit, attempts, pi);
sum += calcPi;
}
double average = sum / attempts;
pies [j] = average;
}
for (int k = 0; k < pies.length; k++)
{
System.out.printf( "Trial [" + k +"]: pi = " + "%8.6f \n", pies [k]);
}
}
}