Advertisement
Guest User

Untitled

a guest
Jul 18th, 2018
223
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.86 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 = 0;
  17.             for (int i = 0; i < input.length(); i++){
  18.                 currentSum += input.charAt(i);
  19.             }
  20.             if (currentSum > maxSum){
  21.                 maxSum = currentSum;
  22.                 nameWithMaxSum = input;
  23.             }
  24.         }
  25.         System.out.printf("Winner is %s - %s!%n", nameWithMaxSum, maxSum);
  26.     }
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement