Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class BestPlayer_05 {
- public static void main(String[] args) {
- Scanner myScan = new Scanner(System.in);
- String input = "";
- int goals = 0;
- int maxGoals = Integer.MIN_VALUE;
- String bestPlayer = "";
- boolean isHatTrick = false;
- while (true) {
- input = myScan.nextLine();
- if (input.equals("END")) {
- break;
- }
- goals = Integer.parseInt(myScan.nextLine());
- if (goals == maxGoals) {
- continue;
- }
- if (goals > maxGoals) {
- maxGoals = goals;
- bestPlayer = input;
- }
- if (maxGoals >= 3) {
- isHatTrick = true;
- }
- if (maxGoals >= 10) {
- break;
- }
- }
- System.out.printf("%s is the best player!%n", bestPlayer);
- if (isHatTrick) {
- 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