+ 2
Hello please I need some help with the bowling game project in java
They tell me to search the Shashi for the winner with iteration but I keep getting this error <identifier> not found help me guys please
6 Answers
+ 4
This will help you: 
https://code.sololearn.com/cZmNH1Z7uXql/?ref=app
+ 11
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);
    }
    public void getWinner(){
        String best="";
        Iterator<Map.Entry<String,Integer>> it =players.entrySet().iterator();
        int max=0;
        while(it.hasNext()){
        
         String playerName=it.next().getKey();
      Integer checkVal=players.get(playerName);
          if (checkVal>=max){
        
              max=checkVal;
              best=playerName;
          }
            
        }
        
       System.out.println(best);
    }
    
}
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(" ");
            String name = values[0];
            int points = Integer.parseInt(values[1]);
            game.addPlayer(name, points);
        }
        game.getWinner();
    }
}
+ 3
Uhhh... I've finished the java course. No info.
Hint: Try asking in StackOverflow or Quora
0
JaScript Thanks so much, helped me figure out where i went wrong. followed.
0
Your welcome. I am glad to hear that.
0
Hello! This code runs but in Sololearn the test case 1, 2, and 4 show correct: test case 3 is x and locked test case 4 is checked correct however it is also locked. The program will not allow me to move forward: what am I missing in this code or is there a error in the program?
Somebody anybody: Help!!!!!
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 Winner = "";
    int max = 0;
    players.put("John", 100);
    players.put("James", 55);
    players.put("Julie", 98);
    for(String name: players.keySet()){
        if(players.get(name)>max){
            Winner = name;
            max = players.get(name);
   
   }   
}           
        System.out.println(Winner);
    }
}
     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(" ");
            String name = values[0];
            int points = Integer.parseInt(values[1]);
            game.addPlayer(name, points);
            
    }   
       
        game.getWinner();
        
    }
}



