Advertisement
Kancho

Biggesr_Sum_Name

Feb 18th, 2019
127
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.99 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class Even_Odd_Sum {
  4. public static void main(String[] args) {
  5. Scanner key = new Scanner(System.in);
  6. System.out.print("Name: ");
  7. String name = key.nextLine();
  8. int sumName = 0;
  9. int biggestSum = 0;
  10. String winnerName = "";
  11.  
  12. while (!name.equals("stop")) {
  13. sumName = 0;
  14. for (int i = 0; i < name.length(); i++) {
  15. System.out.print(name.charAt(i) + "=");
  16. System.out.println((int) (name.charAt(i)));
  17. sumName += (int) name.charAt(i);
  18. }
  19. System.out.println("The sum of current name is " + sumName);
  20. if (sumName > biggestSum) {
  21. biggestSum = sumName;
  22. winnerName = name;
  23. }
  24.  
  25. System.out.println("Name or stop: ");
  26. name = key.nextLine();
  27.  
  28. }
  29.  
  30. System.out.printf("The winner name is %s with %d points!", winnerName, biggestSum);
  31. }
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement