Advertisement
markopizzy

Untitled

Nov 9th, 2019
141
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.06 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class Easter_competition {
  4. public static void main(String[] args) {
  5. Scanner scanner = new Scanner(System.in);
  6.  
  7.  
  8. int breads = Integer.parseInt(scanner.nextLine());
  9. int maxScore = 0;
  10. String winner = "";
  11.  
  12. for (int i = 0; i < breads ; i++) {
  13. String name = scanner.nextLine();
  14. int currentMax = 0;
  15. String currentWinner = "";
  16.  
  17.  
  18. while (!"Stop".equals(name)){
  19. int score = Integer.parseInt(scanner.nextLine());
  20.  
  21. currentMax += score;
  22.  
  23. if (currentMax > maxScore) {
  24. maxScore = currentMax;
  25. currentWinner = winner;
  26. }
  27. name = scanner.nextLine();
  28. }
  29. System.out.printf("%s has %d points.", currentWinner, currentMax);
  30. if(currentMax >= maxScore) {
  31. winner = currentWinner;
  32. System.out.printf("%s is the new number 1!", winner);
  33.  
  34. }
  35. }
  36. }
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement