import java.io.*;

public class Approx{
public static void main(String[] args){
int i,n=10000;
int k=0;
double x,y,ap;
PrintWriter fo;
try{
fo=new PrintWriter(
new BufferedWriter(
new FileWriter(args[0])));
for(i=0;i<n;i++){
x=2*Math.random()-1;
y=Math.random();
if((x*x*1)*y<x*x)
k++;
}
ap=4.0*k/n;
fo.println("近似値="+ap);
fo.close();
}
catch(Exception e){
System.out.println("書き込みエラー"+e);
}
}
}

以上です。よろしくお願いします。