Advertisement
Guest User

Untitled

a guest
Jul 18th, 2018
137
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.76 KB | None | 0 0
  1. import java.io.BufferedReader;
  2. import java.io.IOException;
  3. import java.io.InputStreamReader;
  4.  
  5. public class Main {
  6.     public static void main(String[] args) throws IOException {
  7.         BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
  8.         String input;
  9.         int maxSum = 0;
  10.         String nameWithMaxSum = "";
  11.         while (true){
  12.             input = reader.readLine();
  13.             if (input.equals("STOP")){
  14.                 break;
  15.             }
  16.             int currentSum = input.chars().sum();
  17.             if (currentSum > maxSum){
  18.                 maxSum = currentSum;
  19.                 nameWithMaxSum = input;
  20.             }
  21.         }
  22.         System.out.printf("Winner is %s - %s!%n", nameWithMaxSum, maxSum);
  23.     }
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement