Advertisement
Spocoman

Best Player

Sep 1st, 2024
295
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.94 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class Main {
  4.     public static void main(String[] args) {
  5.         Scanner scanner = new Scanner(System.in);
  6.         String command, currentPlayer, bestPlayer = "";
  7.         int currentPlayerGoals, bestPlayerGoals = 0;
  8.  
  9.         while (bestPlayerGoals < 10 && !(command = scanner.nextLine()).equals("END")) {
  10.             currentPlayer = command;
  11.             currentPlayerGoals = Integer.parseInt(scanner.nextLine());
  12.             if (currentPlayerGoals > bestPlayerGoals) {
  13.                 bestPlayer = currentPlayer;
  14.                 bestPlayerGoals = currentPlayerGoals;
  15.             }
  16.         }
  17.  
  18.         System.out.printf("%s is the best player!\n", bestPlayer);
  19.  
  20.         if (bestPlayerGoals < 3) {
  21.             System.out.printf("He has scored %d goals.\n", bestPlayerGoals);
  22.         } else {
  23.             System.out.printf("He has scored %d goals and made a hat-trick !!!\n", bestPlayerGoals);
  24.         }
  25.     }
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement