Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

2. A. In Chapter 4, you created a Die application that randomly throws five dice for the computer and five dice for the player. The

2. A. In Chapter 4, you created a Die application that randomly "throws" five dice for the computer and five dice for the player. The application displays the values. Modify the application to decide the winner based on the following hierarchy of Die values. Any higher combination beats a lower one-for example, five of a kind beats four of a kind.

-Five of a kind

-Four of a kind

-Three of a kind

-A pair

For this game, the dice values do not count: for example, if both players have three of a kind, its a tie, no matter what the values of the three dice are. Additionally, the game does not recognize a full house (three of a kind plus two of a kind). Save the application as FiveDice2.java

B. Improve the FiveDice2 game so that when both players have the same combination of dice, the higher value wins. For example two 6s beat two 5s. Save the application as FiveDice3.java.

********* I NEED TO ANSWER QUESTION 2B************

********QUESTION 2B IS IN BOLD*******************

I am having trouble answering one of my questions and need help. PLEASE!!!

I have written out both parts of the question to help get an idea of what the problem needs to include. My homework question is 2B

Here is what i have so far from what i originally did....

import java.util.*; public class FiveDice //class header { //setting the lowest and highest variables to 1 and 6 //to get what will be the range of the dice private static final int LOWEST_DIE_VALUE = 1; private static final int HIGHEST_DIE_VALUE = 6; public int getDice() { //getting a random number 1 to 6 for the dice int dice = ((int)(Math.random() * 6) % HIGHEST_DIE_VALUE + LOWEST_DIE_VALUE); return dice; } public static void main(String[] args) // method header { FiveDice now = new FiveDice(); //getting 5 random dice for the computer int compDice1 = now.getDice(); int compDice2 = now.getDice(); int compDice3 = now.getDice(); int compDice4 = now.getDice(); int compDice5 = now.getDice(); //getting 5 random dice for the user int userDice1 = now.getDice(); int userDice2 = now.getDice(); int userDice3 = now.getDice(); int userDice4 = now.getDice(); int userDice5 = now.getDice(); //displaying the 5 dice rolled for the computer System.out.println("The computers dice are: "); System.out.println(compDice1); System.out.println(compDice2); System.out.println(compDice3); System.out.println(compDice4); System.out.println(compDice5); //displaying the 5 dice rolled for the user System.out.println(" The users dice are: "); System.out.println(userDice1); System.out.println(userDice2); System.out.println(userDice3); System.out.println(userDice4); System.out.println(userDice5); } }

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Processing

Authors: David M. Kroenke, David Auer

11th Edition

B003Y7CIBU, 978-0132302678

More Books

Students also viewed these Databases questions

Question

1. Communicating courses and programs to employees.

Answered: 1 week ago

Question

Discuss the Rights issue procedure in detail.

Answered: 1 week ago

Question

Discuss the Rights issue procedure in detail.

Answered: 1 week ago

Question

Explain the procedure for valuation of shares.

Answered: 1 week ago

Question

Which months of this year 5 Mondays ?

Answered: 1 week ago

Question

Define Leap year?

Answered: 1 week ago