Advertisement
remote87

best player

Apr 19th, 2021
911
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.84 KB | None | 0 0
  1. package com.company;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class Main {
  6.  
  7.     public static void main(String[] args) {
  8.         Scanner scan = new Scanner(System.in);
  9.         String name = scan.nextLine();
  10.         int goals = 0;
  11.         int maxGoals = 0;
  12.         String bestPlayer = "";
  13.  
  14.         while(!name.equals("END")){
  15.             goals = Integer.parseInt(scan.nextLine());
  16.             if(goals > maxGoals){
  17.                 maxGoals = goals;
  18.                 bestPlayer = name;
  19.             }
  20.             if(goals == 10) name = "END";
  21.             else name = scan.nextLine();
  22.         }
  23.         System.out.println(bestPlayer + " is the best player!");
  24.         if(maxGoals >= 3) System.out.printf("He has scored %d goals and made a hat-trick !!!\n", maxGoals);
  25.         else System.out.printf("He has scored %d goals.", maxGoals);
  26.     }
  27. }
  28.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement