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