Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

How to I change this code to print the highest value(s) in the array? The wanted output (you just need to make it print the

How to I change this code to print the highest value(s) in the array? The wanted output (you just need to make it print the winner, ignore what comes before) is included below:

image text in transcribed

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

public static void playGame(int players, int cards) {

if (players * cards > 52) {

System.out.println("Not enough cards for that many players.");

return;

}

boolean[] deck = new boolean[52];

int[] playerScore = new int[players];

for (int i = 0; i

System.out.println("Player " + (i + 1));

int[] hand = Cards.dealHandFromDeck(cards, deck);

Cards.printHand(hand);

System.out.println("Score = " + Cards.pointValue(hand));

System.out.println();

playerScore[i] = Cards.pointValue(hand);

}

//go through playerScore array twice, first to find the highest score, then print which player(s) have that score

Example:s Player 1 4/S J/D Score 1 Player 1 K/H 9/D Score 1 Player 1 9/C J/H Score 1 Player 2 2/C T/C Score -2 Player 2 2/S A/C Score 3 Player 2 5/H J/C Score 1 Player 3 J/S 9/H Score 1 Player 3 K/S Q/D Score 3 Player 3 J/S 8/H Score 1 Player 2 is a winner. Player 2 is a winner. Player 3 is a winner Player 1 is a winner. Player 2 is a winner Player 3 is a winner

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 101

Authors: Guy Kawasaki

1st Edition

0938151525, 978-0938151524

More Books

Students also viewed these Databases questions

Question

Provide examples of KPIs in Human Capital Management.

Answered: 1 week ago

Question

What are OLAP Cubes?

Answered: 1 week ago