Advertisement
veronikaaa86

06. Easter Competition

Jun 18th, 2022
288
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.11 KB | None | 0 0
  1. package examPrep;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class P06EasterCompetition {
  6. public static void main(String[] args) {
  7. Scanner scanner = new Scanner(System.in);
  8.  
  9. int easterBreadCount = Integer.parseInt(scanner.nextLine());
  10.  
  11. int maxPoints = Integer.MIN_VALUE;
  12. String winnerName = "";
  13. for (int i = 0; i < easterBreadCount; i++) {
  14. String name = scanner.nextLine();
  15.  
  16. int totalPoints = 0;
  17. String input = scanner.nextLine();
  18. while (!input.equals("Stop")) {
  19. int currentPoint = Integer.parseInt(input);
  20.  
  21. totalPoints += currentPoint;
  22.  
  23. input = scanner.nextLine();
  24. }
  25.  
  26. System.out.printf("%s has %d points.%n", name, totalPoints);
  27.  
  28. if (totalPoints > maxPoints) {
  29. maxPoints = totalPoints;
  30. winnerName = name;
  31. System.out.printf("%s is the new number 1!%n", name);
  32. }
  33. }
  34.  
  35. System.out.printf("%s won competition with %d points!%n", winnerName, maxPoints);
  36. }
  37. }
  38.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement