Ok, so basically I am supposed to "Write a program that uses the Monte Carlo sampling method to estimate the average number of bottles of Boost someone would have to drink to win a prize."

I know that I am supposed to First, work on the part that conducts trials and print the results to the screen. Second, print the results of each trial to an outFile. Check the file to verify it matches the screen output. Third, read the trial data back in and calculate the average. Fourth, print the results.

Ok so here is what I have so far

import java.util.Scanner;
import java.util.Random;
import java.io.IOException;
import java.io.PrintWriter;
import java.io.File;
public class BottleCap
    public static void main(String [] args)throws IOException
        int trials = 20;
        int count = 0;
        Scanner in;  
        in = new Scanner(System.in);
          int  randomnumber = ((int)(0+ Math.random()* 999));
        PrintWriter outFile = new PrintWriter(new File("bcp.txt"));
        for(int loop = 1; loop <= 20;)
             int  randomNumber = ((int)(0+ Math.random()* 999));
        outFile.close ();
        Scanner inFile = new Scanner(outFile);

Im not really sure I am doing it right or even headed in the right direction... Any ideas?

Monte Carlo isn't a method, it is the set of algorithms that use repeated random sampling to compute their results, according to wikipedia. So my question is: if that is the case, then don't you have to design an algorithm to estimate the # bottles of Boost before you even begin coding?

I am supposed to start with 20 trials while trying to figure out the code, then the final code should have 1000 trials. Which I am guessing that by trials they mean bottles. If that is what you mean by estimating the number of bottles....