Question: Implement a Java program that simulates the rolling of 2 dice and then evaluates the dice roll to determine points scored based on the games

Implement a Java program that simulates the rolling of 2 dice and then evaluates the dice roll to determine points scored based on the games rules. Total points are the sum of the 2 dice plus bonus points for rolling a pair (aka doubles), a 7, or an 11(aka a natural). If the roll is 2,3, or 12(aka craps), the score for the roll is zero irrespective of the dice values. In the case of 2 or 12, the pair bonus is nullified because of the zero for rolling craps. Functional Requirements (how the code will work from the user perspective) System prompts the player for their name (one name only) and reads the input via Scanner. System displays a welcome message to the user on the console, including the users name, and prints the rules of the game. System prompts the user to enter any character to start the game. System rolls the dice and displays the dice values from low to high. System evaluates the dice values and calculates total score for the roll. System prints the dice values and total score from the roll, the date, and the elapsed time in milliseconds. System prints values of pairBonus and seven11Bonus. System ends the game by printing an end-of-game message. Technical Requirements (how you must code it)The system should include the following Java components: System consists of the following sections.o Declare variables.o Create objects for Scanner (scan), Random (rand) and LocalDate (date) classes. Get date using LocalDate date = LocalDate.now(); Note: date is the variable name that includes the value for todays date.o Prompt for and read-in users name using Scanner (first name only).o Prompt for player to roll the dice using Scanner by entering any character.o Use System.currentTimeMillis, e.g., startTime = System.currentTimeMillis(); to set the start time, end time, and then calculate the elapsed time.o Generate the dice values using Random class.o Display the dice values in sequence from low to high. Variables required.o String nameo int die1o int die2o int sumo int pairBonuso int seven11Bonuso int totalo int tempDie // Use this var when sorting the dice before displaying them Selection type statements that can be used (you do not need to use all of them):o ifo if-elseo nested if or nested if-elseo conditional operators (&& or ||) Variables should be declared at the beginning of the main method. To read in the name, use: scan.next(); Algorithm for generating the random die values should use the Random class.o Random rand = new Random(); // Creates the Random class object randomo die1= rand.nextInt(6)+1; // Assigns random value 1-6 to die1o die2= rand.nextInt(6)+1; // Assigns random value 1-6 to die2

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!