galinyotsev123

ProgBasicsExam28and29July2018-E04bestPlayer

Dec 28th, 2018
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.11 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class E04bestPlayer {
  4. public static void main(String[] args) {
  5. Scanner scanner = new Scanner(System.in);
  6.  
  7. int highestScore = 0;
  8. String playerWithHighestScore = "";
  9.  
  10.  
  11.  
  12. while (true)
  13.  
  14. {
  15. String player = scanner.nextLine();
  16. if (player.equalsIgnoreCase("END"))
  17. break;
  18.  
  19. int goals = Integer.parseInt(scanner.nextLine());
  20.  
  21. if (goals > highestScore)
  22. {
  23. highestScore = goals;
  24. playerWithHighestScore = player;
  25. }
  26.  
  27. if (goals >= 10)
  28. break;
  29. }
  30.  
  31. if (highestScore >= 3)
  32. {
  33. System.out.printf("%s is the best player!%n", playerWithHighestScore);
  34. System.out.printf("He has scored %d goals and made a hat-trick !!!", highestScore);
  35. }
  36.  
  37. else
  38. {
  39. System.out.printf("%s is the best player!%n", playerWithHighestScore);
  40. System.out.printf("He has scored %d goal!", highestScore);
  41. }
  42.  
  43.  
  44. }
  45. }
Advertisement
Add Comment
Please, Sign In to add comment