Dice Game (class,enum,interface expected error) - Programmers Heaven

Howdy, Stranger!

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

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

Dice Game (class,enum,interface expected error)

FLDancingQueenFLDancingQueen Posts: 1Member
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!!
~FLDancingQueen

/*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();


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

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);
numRolls++;

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.