I am struggling and really need a solution to this problem i

I am struggling and really need a solution to this problem in the the Java Programming textbook, chapter 4, game zone #2: Using the Die class, write an application that randomly \"throws\" five dice for the computer and five dice for the player. Display the values and then, by observing the results, decide who wins based on the following hierarchy of Die values. (The computer will not decide the winner; the player will determine the winner based on observation.) 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

After you learn about decision making in the next chapter, you will be able to make thei program determine whether you or the computer had the better roll, and after you read the chapter Arrays, you will be able to make the determination more efficient. For now, just observe how the values change as you execute the program multiple times. Save the application as FiveDice.java.

Solution

package chegg;


import java.util.Random;

public class Die {
  
   /*create a methos that generate random number between 1 to 6*/
   int dice_throws()  
   {
       /* Random is java method that use for generate random number*/
       Random rand = new Random();

       /* random number generation method is rand.nextInt((max - min) + 1) + min;
       * here max is maximum value and min is minimum value
       * in a dice thorw max value is 6 and min value is 1*/
       int random_number = rand.nextInt((6 - 1) + 1) + 1;

       /* retun random_number from method*/
       return random_number;
      
   }
  
   /*main methd*/
   public static void main(String[] args) {
       /*create a object of class Die*/
       Die d=new Die();
      
       /*generate Randomly throws five dice number for the computer */
       System.out.println(\"Randomly throws five dice for the computer\");
       for(int i=0;i<5;i++)
       System.out.println(\"on throw \"+ (i+1)+\" dice number is :\"+ d.dice_throws());
      
       System.out.println();
       /*generate Randomly throws five dice number for the player */
      
       System.out.println(\"Randomly throws five dice for the player\");
       for(int i=0;i<5;i++)
       System.out.println(\"on throw \"+ (i+1) +\" dice number is :\"+ d.dice_throws());
      
   }

}// end of class

--------------------------

output sample 1;

Randomly throws five dice for the computer
on throw 1 dice number is :6
on throw 2 dice number is :4
on throw 3 dice number is :4
on throw 4 dice number is :2
on throw 5 dice number is :3


Randomly throws five dice for the player
on throw 1 dice number is :5
on throw 2 dice number is :5
on throw 3 dice number is :2
on throw 4 dice number is :6
on throw 5 dice number is :4

output sample:2

Randomly throws five dice for the computer
on throw 1 dice number is :6
on throw 2 dice number is :5
on throw 3 dice number is :1
on throw 4 dice number is :2
on throw 5 dice number is :6

Randomly throws five dice for the player
on throw 1 dice number is :4
on throw 2 dice number is :6
on throw 3 dice number is :4
on throw 4 dice number is :6
on throw 5 dice number is :3

after this you have to observe who is winner

for that you can make pair of dice number and check which is greater.

so greater number will be winner.

---------------------------------------------------------------------------------------------

If you have any query, please feel free to ask

Thanks a lot

I am struggling and really need a solution to this problem in the the Java Programming textbook, chapter 4, game zone #2: Using the Die class, write an applicat
I am struggling and really need a solution to this problem in the the Java Programming textbook, chapter 4, game zone #2: Using the Die class, write an applicat

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site