Ligh7_of_H3av3n

04. Best Player

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