Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class NameWars {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- String input = scanner.nextLine();
- String name = "";
- int maxComb = Integer.MIN_VALUE;
- while (!"STOP".equals(input)) {
- int currentSum = 0;
- for (int i = 0; i < input.length(); i++) {
- currentSum+=(int)(input.charAt(i));
- }
- if(currentSum>maxComb){
- maxComb=currentSum;
- name=input;
- input = scanner.nextLine();
- }
- }
- System.out.printf("Winner is %s - %d!", name, maxComb);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement