Advertisement
Guest User

Untitled

a guest
Jun 19th, 2019
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.89 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class Best {
  4.     public static void main(String[] args) {
  5.         Scanner scanner = new Scanner(System.in);
  6.         int maxGoals = Integer.MIN_VALUE;
  7.         String bestPlayer = "";
  8.  
  9.         String name = scanner.nextLine();
  10.         while (!"END".equals(name)) {
  11.             int countGoals = Integer.parseInt(scanner.nextLine());
  12.  
  13.             if (countGoals > maxGoals) {
  14.                 maxGoals = countGoals;
  15.                 bestPlayer = name;
  16.  
  17.             }
  18.             if (countGoals >= 10) break;
  19.             name = scanner.nextLine();
  20.         }
  21.         System.out.printf("%d is the best player!", bestPlayer);
  22.         if (maxGoals >= 3) {
  23.             System.out.printf("%s has scored %d goals and made a hat-trick !!!", name, maxGoals);
  24.         } else {
  25.             System.out.printf("%s has scored %d goals.", name, maxGoals);
  26.         }
  27.     }
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement