Holes in a text- wrong answer

Here is my code. Please help with the error.

import java.io.*;
 
public class Main
{
    public static void main(String args[])throws Exception
    {
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
        int t=Integer.parseInt(br.readLine());
        for(int j=1;j<=t;j++)
        {
            String st=br.readLine();
            int i,count=0;
            for(i=0;i<st.length();i++)
            {
                    if((st.charAt(i)=='A')||(st.charAt(i)=='D')||(st.charAt(i)=='O')||(st.charAt(i)=='P')||(st.charAt(i)=='R'))
                    {count=count+1;}
                    if(st.charAt(i)=='B')
                    {count=count+2;}
            }
            System.out.println(count);
        }
    }
}

i think You forget to mention letter ‘Q’ .hope this help :slight_smile:

2 Likes

yes, the letter q, thanks i got it right…:slight_smile:

if the letter ‘Q’ is encountered then also you have to increment count…this is your corrected code…:slight_smile:

//