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