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 scanner = new Scanner(System.in);
- int easterBreadCount = Integer.parseInt(scanner.nextLine()),
- bakerpoints, topPoints = 0;
- String baker, command, topBaker = "";
- for (int i = 0; i < easterBreadCount; i++) {
- baker = scanner.nextLine();
- bakerpoints = 0;
- while (!(command = scanner.nextLine()).equals("Stop")) {
- bakerpoints += Integer.parseInt(command);
- }
- if (topPoints < bakerpoints) {
- topBaker = baker;
- topPoints = bakerpoints;
- System.out.println(topBaker + " has " + topPoints + " points.\n" + topBaker + " is the new number 1!");
- } else {
- System.out.println(baker + " has " + bakerpoints + " points.");
- }
- }
- System.out.println(topBaker + " won competition with " + topPoints + " points!");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement