fork(1) download
  1.  
  2. import java.util.Scanner;
  3. import java.io.*;
  4. class HOLES
  5. {
  6. static BufferedReader br=new BufferedReader(isr);
  7. // A B-2 D O P Q R
  8. public static void main(String args[])
  9. {
  10. Scanner input=new Scanner(System.in);
  11. int count,i,j,len,t;
  12. //System.out.println("Enter the number of test cases");
  13. try
  14. {
  15. t=input.nextInt();
  16. while(t>0)
  17. //for(i=1;i<=t;i++)
  18. {
  19.  
  20. //System.out.println("enter the text");
  21. String s=br.readLine();
  22.  
  23. count=0;
  24. len=s.length();
  25. if(len>=100)
  26. len=99;
  27. for(i=0;i<len;i++)
  28. {
  29. if((s.charAt(i)=='A') || (s.charAt(i)=='D') || (s.charAt(i)=='O') || (s.charAt(i)=='P') || (s.charAt(i)=='Q') || (s.charAt(i)=='R'))
  30. {
  31. count++;
  32. }
  33. else if(s.charAt(i)=='B')
  34. {
  35. count=count+2;
  36. }
  37. else
  38. {
  39. continue;
  40. }
  41. }
  42. System.out.println(count);
  43. t--;
  44. }
  45. }
  46. catch(Exception e)
  47. {
  48. System.err.println(e);
  49. }
  50. }
  51. }
  52.  
Success #stdin #stdout #stderr 0.09s 380672KB
stdin
2
CODECHEF
DRINKEATCODE
stdout
Standard output is empty
stderr
java.lang.NullPointerException