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