Im new to this site so the format of this post may be sub par. I have been working on this code and I cannot seem to figure out why when option one is chosen it asks for the number and does nothing. Thank you for any feedback you may be able to assist me with.
import java.util.*;
public class Lab12
{
// Code for implementing option 1 of lab assignment
// Roll three six-sided dice until they all show a different number
// Print out the result
public static void option1()
{
//System.out.println("Executing option 1");
// Code goes here
Dice die1 = new Dice();
Dice die2 = new Dice();
Dice die3 = new Dice();
boolean finished = false;
int getNumRolls;
int count = 0;
int r1 = die1.roll();
int r2 = die2.roll();
int r3 = die3.roll();
while (!finished)
{
//int r1 = die1.roll();
//int r2 = die2.roll();
//int r3 = die3.roll();
if (r1 != r2) {
r1 = die1.roll();
r2 = die2.roll();
r3 = die3.roll();
}
else if (r2 != r3) {
r1 = die1.roll();
r2 = die2.roll();
r3 = die3.roll();
}
else if (r3 != r1) {
finished = true;
//System.out.println("It took " + count + " rolls to roll three different numbers: " + r1 + ", " + r2 +", " + r3 + ".");
}
}
getNumRolls = die1.getNumRolls();
System.out.println("It took " + getNumRolls + " rolls to roll three different numbers: " + r1 + ", " + r2 +", " + r3 + ".");
}
// Code for implementing option 2 of lab assignment
// Roll the two dice n times and print the average.
public static void option2(int n)
{
//System.out.println("Executing option 2");
Dice die1 = new Dice();
Dice die2 = new Dice();
int r1 = 0;
int r2 = 0;
for (int i = 1; i <= n; i++) {
r1 = r1 + die1.roll();
r2 = r2 + die2.roll();
}
int avg = (r2+r1)/n;
System.out.println("The average of " + n + " roll(s) of the two dice is " + avg);
// Code goes here
}
// Must add code to main for system prompts and Case 3
public static void main(String [] args)
{