Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.company;
- import java.util.Scanner
- public class EasterShop {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- int cakesToBeAppraised = Integer.parseInt(scanner.nextLine());
- int bestScore = 0;
- String bestConfectioner = "";
- for (int i = 0; i < cakesToBeAppraised; i++) {
- String currentConfectioner = scanner.nextLine();
- int currentConfectionerScore = 0;
- while(true){
- String inputLine = scanner.nextLine();
- if (inputLine.equalsIgnoreCase("Stop"))
- break;
- int currentJudgeScore = Integer.parseInt(inputLine);
- currentConfectionerScore += currentJudgeScore;
- }
- System.out.printf("%s has %d points.\n", currentConfectioner, currentConfectionerScore);
- if (bestScore < currentConfectionerScore ){
- bestScore = currentConfectionerScore;
- bestConfectioner = currentConfectioner;
- System.out.printf("%s is the new number 1!\n", bestConfectioner);
- }
- }
- System.out.printf("%s won competition with %d points!", bestConfectioner, bestScore);;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement