Question
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:
--------------------------------------------------------------------------------------------
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 winnerStep 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