Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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 dice and then evaluates the dice roll to determine points scored based on the games rules. Total points are the sum of the dice plus bonus points for rolling a pair aka doubles a or an aka a natural If the roll is or aka craps the score for the roll is zero irrespective of the dice values. In the case of or 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 sevenBonus. System ends the game by printing an endofgame message. Technical Requirements how you must code itThe 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 readin users name using Scanner first name onlyo Prompt for player to roll the dice using Scanner by entering any character.o Use System.currentTimeMillis, eg 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 dieo int dieo int sumo int pairBonuso int sevenBonuso 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 ifelseo nested if or nested ifelseo 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 die rand.nextInt; Assigns random value to dieo die rand.nextInt; Assigns random value to die
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started