Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class Main {
- public static void main(String[] args) {
- Scanner scan = new Scanner(System.in);
- int sweetBread = Integer.parseInt(scan.nextLine());
- int maxPoints = 0;
- String bakerWithMaxPoints = "";
- for (int i = 0; i < sweetBread; i++) {
- int currentPoints = 0;
- String bakerName = scan.nextLine();
- String input = scan.nextLine();
- while (!"Stop".equals(input)) {
- int points = Integer.parseInt(input);
- currentPoints += points;
- input = scan.nextLine();
- }
- System.out.printf("%s has %d points.%n", bakerName, currentPoints);
- if (currentPoints > maxPoints) {
- maxPoints = currentPoints;
- bakerWithMaxPoints = bakerName;
- System.out.printf("%s is the new number 1!%n", bakerWithMaxPoints);
- }
- }
- System.out.printf("%s won competition with %d points!", bakerWithMaxPoints, maxPoints);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement