Advertisement
mtsonkova

Untitled

Feb 19th, 2023
26
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.00 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class BestPlayer {
  4. public static void main(String[] args) {
  5. Scanner scanner = new Scanner(System.in);
  6.  
  7. String bestPlayer = "";
  8. int maxGoals = 0;
  9.  
  10. while(true) {
  11. String name = scanner.nextLine();
  12.  
  13. if(name.equals("END")) {
  14. break;
  15. }
  16.  
  17. int goals = Integer.parseInt(scanner.nextLine());
  18.  
  19. if(goals > maxGoals) {
  20. maxGoals = goals;
  21. bestPlayer = name;
  22. }
  23.  
  24. if(goals >= 10) {
  25. break;
  26. }
  27.  
  28. }
  29.  
  30. if (maxGoals >= 3) {
  31. System.out.printf("%s is the best player! \n", bestPlayer);
  32. System.out.printf("He has scored %d goals and made a hat-trick !!!", maxGoals);
  33. } else {
  34. System.out.printf("%s is the best player! \n", bestPlayer);
  35. System.out.printf("He has scored %d goals.", maxGoals);
  36. }
  37.  
  38. }
  39. }
  40.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement