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