Advertisement
Guest User

Untitled

a guest
Apr 20th, 2019
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.39 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class otGosho {
  4. public static void main(String[] args) {
  5. Scanner scanner = new Scanner(System.in);
  6.  
  7.  
  8. int easterBreadCount = Integer.parseInt(scanner.nextLine());
  9. String winnerName = "";
  10. int winnerPoints = 0;
  11.  
  12. for (int i = 0; i < easterBreadCount; i++)
  13. {
  14. String chefName = scanner.nextLine();
  15. int chefPoints = 0;
  16. String command = "";
  17.  
  18. while (true)
  19. {
  20. command = scanner.nextLine();
  21.  
  22. if (command.equals("Stop"))
  23. {
  24. System.out.printf("%s has %d points.%n",chefName,chefPoints);
  25.  
  26. break;
  27. }
  28. else
  29. {
  30. int pointBonus = Integer.parseInt(command);
  31. chefPoints += pointBonus;
  32. }
  33. }
  34.  
  35. if (chefPoints > winnerPoints)
  36. {
  37. winnerName = chefName;
  38. winnerPoints = chefPoints;
  39. System.out.printf("%s is the new number 1!%n",chefName);
  40. }
  41. }
  42.  
  43. System.out.printf("%s won competition with %d points!",winnerName,winnerPoints);
  44. }
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement