We need to develop a game that allows two players to throw a dice ten times and the player who gets the highest sum wins the game. Write a method sum(int[] values) that returns the sum of elements of the array values. Write a method display(int[] values) that displays the elements of the array values. • Write a main method where you should: a) Create two arrays of integers called player1 and player2 with size 10 both b) For each player, generate ten random integers between 1 and 6 inclusively. The generated values are added to the associated array of each player. c) Display the generated values for each player. d) Find and display the winner using the sum method. I Sample run1 Generated numbers for player 1 are: 6 6 31 2 1 4 65 4 Generated numbers for player 2 are: 6 2 2 4 2 1 1 52 4 Player 1 wins with score 38 Sample run2 Generated numbers for player 1 are: 352 32 1465 4 Generated numbers for player 2 are: 5 3 3 2 2 1 65 4 4 Draw with score 35

Programming Logic & Design Comprehensive
9th Edition
ISBN:9781337669405
Author:FARRELL
Publisher:FARRELL
Chapter9: Advanced Modularization Techniques
Section: Chapter Questions
Problem 2GZ
icon
Related questions
Question
100%
Please solve it by java
We need to develop a game that allows two players to throw a dice ten times and the player who gets the highest
sum wins the game.
Write a method sum(int[] values) that returns the sum of elements of the array values.
Write a method display(int[] values) that displays the elements of the array values.
Write a main method where you should:
a) Create two arrays of integers called player1 and player2 with size 10 both
b) For each player, generate ten random integers between 1 and 6 inclusively. The generated values
are added to the associated array of each player.
c) Display the generated values for each player.
d) Find and display the winner using the sum method.
Sample run1
Generated numbers for player 1 are:
Generated numbers for player 2 are: 6 2 2 4 2 1 1 5 2 4
Player 1 wins with score 38
Sample run2
Generated numbers for player 1 are: 3 52 321 465 4
Generated numbers for player 2 are:
Draw with score 35
6 63 12 1 4 6 5 4
5 33 2 2 1 6 5 4 4
Transcribed Image Text:We need to develop a game that allows two players to throw a dice ten times and the player who gets the highest sum wins the game. Write a method sum(int[] values) that returns the sum of elements of the array values. Write a method display(int[] values) that displays the elements of the array values. Write a main method where you should: a) Create two arrays of integers called player1 and player2 with size 10 both b) For each player, generate ten random integers between 1 and 6 inclusively. The generated values are added to the associated array of each player. c) Display the generated values for each player. d) Find and display the winner using the sum method. Sample run1 Generated numbers for player 1 are: Generated numbers for player 2 are: 6 2 2 4 2 1 1 5 2 4 Player 1 wins with score 38 Sample run2 Generated numbers for player 1 are: 3 52 321 465 4 Generated numbers for player 2 are: Draw with score 35 6 63 12 1 4 6 5 4 5 33 2 2 1 6 5 4 4
Expert Solution
steps

Step by step

Solved in 2 steps with 1 images

Blurred answer
Knowledge Booster
Time complexity
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Programming Logic & Design Comprehensive
Programming Logic & Design Comprehensive
Computer Science
ISBN:
9781337669405
Author:
FARRELL
Publisher:
Cengage