Need help pls... whats to put here | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 4

Need help pls... whats to put here

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 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(); } }

29th Nov 2020, 10:45 AM
Dannica F. Yano
Dannica F. Yano - avatar
8 Answers
+ 3
The basic solution can be i.e. like this: https://code.sololearn.com/cZmNH1Z7uXql/?ref=app
29th Nov 2020, 1:10 PM
JaScript
JaScript - avatar
0
You should add the `getWinner` method and find out the player with the highest score.
29th Nov 2020, 1:11 PM
o.gak
o.gak - avatar
0
Hi
29th Nov 2020, 6:56 PM
Pon kedah Pon
Pon kedah Pon - avatar
0
Thank you JaScript it works, Thank you everyone very much appreciated.
17th Dec 2020, 11:00 AM
Dannica F. Yano
Dannica F. Yano - avatar
0
Your welcome Dannica Yano
17th Dec 2020, 11:41 AM
JaScript
JaScript - avatar
- 1
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 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(); } }
4th Mar 2021, 8:30 PM
Haritap Kumar
Haritap Kumar - avatar
- 2
You are creating a bowling game! The given code declares a Bowling class with its constructor and addPlayer() method. Each player of the game has a name and points, and are stored in the players HashMap. The code in main takes 3 players data as input and adds them to the game. You need to add a getWinner() method to the class, which calculates and outputs the name of the player with the maximum points. Sample Input: Dave 42 Amy 103 Rob 64 Sample Output: Amy
18th Mar 2021, 1:24 PM
Mouh Salhi
Mouh Salhi - avatar
- 5
Please answer me
4th Mar 2021, 8:30 PM
Haritap Kumar
Haritap Kumar - avatar