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