help with loops with source code
hi, i'm having trouble with this assignment.
3. Determine how many times a die must be rolled in order to
win a prize. (This represents one trial.) Print this value to a
4. Conduct at least 1,000 trials.
5. Read the data back in from all of the trials.
6. Calculate the average number of times a die must be rolled in order to win a prize.
7. Print the result to the screen
This is what I have so far.
But there is something wrong with the loop.
* Write a description of class BottleCapPrize here.
* @author (your name)
* @version (a version number or a date)
public class BottleCapPrize
public static void main (String [ ] args) throws IOException
PrintWriter outFile = new PrintWriter(new File("bah.txt"));
Random randomGenerator = new Random();
int random = randomGenerator.nextInt(5);
int count = 0;
while(random != 3)
for (int loop = 1; loop <= 1000; loop++)
System.out.println("About to check with random=" + random);
if(random == 3) // the altered code
outFile.println("Congratulations, both pairs matched.");
outFile.close ( );