Advertisement
elena_tasheva

Untitled

Oct 24th, 2019
146
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.79 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class NameWars {
  4. public static void main(String[] args) {
  5. Scanner scanner = new Scanner(System.in);
  6. String input = scanner.nextLine();
  7. String name = "";
  8.  
  9. int maxComb = Integer.MIN_VALUE;
  10.  
  11. while (!"STOP".equals(input)) {
  12. int currentSum = 0;
  13. for (int i = 0; i < input.length(); i++) {
  14. currentSum+=(int)(input.charAt(i));
  15. }
  16. if(currentSum>maxComb){
  17. maxComb=currentSum;
  18. name=input;
  19. input = scanner.nextLine();
  20. }
  21. }
  22. System.out.printf("Winner is %s - %d!", name, maxComb);
  23.  
  24. }
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement