Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.io.BufferedReader;
- import java.io.IOException;
- import java.io.InputStreamReader;
- public class Main {
- public static void main(String[] args) throws IOException {
- BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
- String input;
- int maxSum = 0;
- String nameWithMaxSum = "";
- while (true){
- input = reader.readLine();
- if (input.equals("STOP")){
- break;
- }
- int currentSum = 0;
- for (int i = 0; i < input.length(); i++){
- currentSum += input.charAt(i);
- }
- if (currentSum > maxSum){
- maxSum = currentSum;
- nameWithMaxSum = input;
- }
- }
- System.out.printf("Winner is %s - %s!%n", nameWithMaxSum, maxSum);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement