Advertisement
markopizzy

Untitled

Nov 9th, 2019
104
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 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 currentScoreCount = 0;
  15. String currentWinner = "";
  16.  
  17. while (!"Stop".equals(name)){
  18. int score = Integer.parseInt(scanner.nextLine());
  19.  
  20. currentScoreCount += score;
  21.  
  22. if (currentScoreCount > maxScore) {
  23. maxScore = currentScoreCount;
  24. currentWinner = winner;
  25. }
  26. name = scanner.nextLine();
  27. }
  28. System.out.printf("%s has %d points.", currentWinner, currentScoreCount);
  29. // if(currentScoreCount >= maxScore) {
  30. // winner = currentWinner;
  31. // System.out.printf("%s is the new number 1!", winner);
  32. //
  33. // }
  34. }
  35. }
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement