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