Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class Best {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- int maxGoals = Integer.MIN_VALUE;
- String bestPlayer = "";
- String name = scanner.nextLine();
- while (!"END".equals(name)) {
- int countGoals = Integer.parseInt(scanner.nextLine());
- if (countGoals > maxGoals) {
- maxGoals = countGoals;
- bestPlayer = name;
- }
- if (countGoals >= 10) break;
- name = scanner.nextLine();
- }
- System.out.printf("%d is the best player!", bestPlayer);
- if (maxGoals >= 3) {
- System.out.printf("%s has scored %d goals and made a hat-trick !!!", name, maxGoals);
- } else {
- System.out.printf("%s has scored %d goals.", name, maxGoals);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement