Advertisement
stoyanoff

FootballPlayer

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