Advertisement
Spocoman

Easter Competition

Sep 4th, 2024
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.03 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class Main {
  4.     public static void main(String[] args) {
  5.         Scanner scanner = new Scanner(System.in);
  6.         int easterBreadCount = Integer.parseInt(scanner.nextLine()),
  7.                 bakerpoints, topPoints = 0;
  8.         String baker, command, topBaker = "";
  9.  
  10.         for (int i = 0; i < easterBreadCount; i++) {
  11.             baker = scanner.nextLine();
  12.             bakerpoints = 0;
  13.  
  14.             while (!(command = scanner.nextLine()).equals("Stop")) {
  15.                 bakerpoints += Integer.parseInt(command);
  16.             }
  17.  
  18.             if (topPoints < bakerpoints) {
  19.                 topBaker = baker;
  20.                 topPoints = bakerpoints;
  21.                 System.out.println(topBaker + " has " + topPoints + " points.\n" + topBaker + " is the new number 1!");
  22.             } else {
  23.                 System.out.println(baker + " has " + bakerpoints + " points.");
  24.             }
  25.         }
  26.         System.out.println(topBaker + " won competition with " + topPoints + " points!");
  27.     }
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement