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