Dice Game (class,enum,interface expected error)

Hey y'all, so I needed to create a dice game that wins when there's a pair, but gives the user the option to continue or quit if they don't roll a pair. Please see code below and any assistance is greatly appreciated. The errors are showing in lines 7, 8, 9. Thankies!!

/*Introduction to Problem Solving and Algorithm Design, Project #4, Nathalie */
import static java.lang.System.out;
import java.util.Scanner;
import java.util.Random;

[color=Red][color=Red]int numRolls = 0;//number of rolls[/color]
[color=Red]int randomNumber1 = new Random().nextInt(6)+1;[/color]
[color=Red]int randomNumber2= new Random().nextInt(6)+1;[/color][/color]
public class DiceGame {//Game Program

public static void main(String[] args) {//Main Module

out.println(" ************ ");
out.println(" Try your luck and roll a pair!! ");
out.println(" ************ ");

out.println("You rolled a " +randomNumber1+ " and a "+randomNumber2);

while (randomNumber1!=randomNumber2){//while dice don't match give the option
int choice;
out.println("Would you like to try again? Press '1' to Continue or '2' to End");
out.println(" ");//Just wanted a space here
Scanner keyboard=new Scanner(System.in);

switch(choice) {//choice to keep rolling start
case 1:
int randomNumber1 = new Random().nextInt(6)+1;
int randomNumber2=new Random().nextInt(6)+1;
out.println("You rolled a " +randomNumber1+ " and a "+randomNumber2);

case 2:
out.print("You chose to end the game without winning after");
out.println(numRolls + " tries.");
}//choice to keep rolling end

}//while dice don't match END

out.print("You won after");
out.println(numRolls + " rolls!");

}//Ends Main Module
}//Ends Game Program

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!