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