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