Advertisement
Lyubohd

06. Easter Competition

Oct 24th, 2020
810
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.07 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class Main {
  4.     public static void main(String[] args) {
  5.         Scanner scan = new Scanner(System.in);
  6.         int sweetBread = Integer.parseInt(scan.nextLine());
  7.         int maxPoints = 0;
  8.         String bakerWithMaxPoints = "";
  9.  
  10.         for (int i = 0; i < sweetBread; i++) {
  11.             int currentPoints = 0;
  12.             String bakerName = scan.nextLine();
  13.             String input = scan.nextLine();
  14.             while (!"Stop".equals(input)) {
  15.                 int points = Integer.parseInt(input);
  16.                 currentPoints += points;
  17.                 input = scan.nextLine();
  18.             }
  19.             System.out.printf("%s has %d points.%n", bakerName, currentPoints);
  20.  
  21.             if (currentPoints > maxPoints) {
  22.                 maxPoints = currentPoints;
  23.                 bakerWithMaxPoints = bakerName;
  24.                 System.out.printf("%s is the new number 1!%n", bakerWithMaxPoints);
  25.             }
  26.         }
  27.  
  28.         System.out.printf("%s won competition with %d points!", bakerWithMaxPoints, maxPoints);
  29.     }
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement