fork download
  1. import java.util.*;
  2.  
  3. class Main{
  4.  
  5. public static void main(String[] args){
  6. Scanner sc = new Scanner(System.in);
  7. int i, tc, j, sum;
  8. char c;
  9. String input;
  10.  
  11. tc = sc.nextInt();
  12. sc.nextLine();
  13. sc.nextLine();
  14. for(i=1; i<=tc; i++){
  15. input = sc.nextLine();
  16. sum = 0;
  17. for(j=0; j<input.length(); j++){
  18. c = input.charAt(j);
  19. if( c=='a' || c=='d' || c=='g' || c=='j' || c=='m' || c=='p' || c=='t' || c=='w' || c==' ' ){
  20. sum += 1;
  21. }
  22. else if( c=='b' || c=='e' || c=='h' || c=='k' || c=='n' || c=='q' || c=='u' || c=='x' ){
  23. sum += 2;
  24. }
  25. else if( c=='c' || c=='f' || c=='i' || c=='l' || c=='o' || c=='r' || c=='v' || c=='y' ){
  26. sum += 3;
  27. }
  28. else if( c=='s' || c=='z' ){
  29. sum += 4;
  30. }
  31. }
  32. System.out.format("Case #%d: %d\n", i, sum);
  33. }
  34. }
  35.  
  36. }
  37.  
Runtime error #stdin #stdout #stderr 0.1s 380736KB
stdin
2
welcome to ulab
good luck and have fun
stdout
Case #1: 41
stderr
Exception in thread "main" java.util.NoSuchElementException: No line found
	at java.util.Scanner.nextLine(Scanner.java:1585)
	at Main.main(Main.java:15)