markopizzy

Untitled

Nov 9th, 2019
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.22 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. String command = scanner.nextLine();
  15.  
  16. int currentScoreCount = 0;
  17. String currentWinner = "";
  18.  
  19. while (!"Stop".equals(command)) {
  20. int score = Integer.parseInt(command);
  21.  
  22. currentScoreCount += score;
  23.  
  24. if (currentScoreCount > maxScore) {
  25. maxScore = currentScoreCount;
  26. currentWinner = name;
  27. }
  28. command = scanner.nextLine();
  29. }
  30. System.out.printf("%s has %d points.%n", name, currentScoreCount);
  31. if (currentScoreCount >= maxScore) {
  32. winner = currentWinner;
  33. System.out.printf("%s is the new number 1!%n", winner);
  34. }
  35. }
  36. System.out.printf("%s won competition with %d points!", winner, maxScore);
  37. }
  38. }
Add Comment
Please, Sign In to add comment