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 name= scanner.nextLine();
- int summax=0;
- String namemax="";
- while(!name.equals("STOP"))
- {
- int sum=0;
- for(int i=0;i<name.length();i++)
- {
- sum=sum+(int)name.charAt(i);
- }
- if (summax<sum)
- {
- summax=sum;
- namemax=name;
- }
- name= scanner.nextLine();
- }
- System.out.printf("Winner is %s - %d!",namemax,summax );
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement