0

Why my code below didnt work

import java.util.*; public class Bowling { HashMap<String, Integer> players; Bowling() { players = new HashMap<String, Integer>(); } public void addPlayer(String name, int p) { players.put(name, p); } //your code goes here public void getWinner() { String[]nameArr=new String[players.size()]; nameArr=players.keySet().toArray(nameArr); String topPlayer=nameArr[6]; int maxVal=players.get(nameArr[4]); for(String player : nameArr){ if(players.get.(player)>maxVal){ topPlayer=player; maxVal=players.get(player); } } System.out.println(topPlayer); } } public class Program { public static void main(String[ ] args) { Bowling game = new Bowling(); Scanner sc = new Scanner(System.in); for(int i=0;i<3;i++) { String input = sc.nextLine(); String[] values = input.split(" ");

1st Jun 2021, 8:42 PM
Windu Wirawan
1 Respuesta
+ 1
your code is incomplete (doesn't fit in the character limit)... better to provide a link to a sololearn code playground project ;P
1st Jun 2021, 9:02 PM
visph
visph - avatar