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