Quantcast
Channel: CodeChef Discuss - latest questions
Viewing all articles
Browse latest Browse all 40121

Holes in a text- wrong answer

$
0
0

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);
        }
    }
}

Viewing all articles
Browse latest Browse all 40121


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>