MY CODE IS GIVING ME PROPER ANSWER ON MY PC BUT AS I UPLOAD IT SOME TIME I GOT COMPILATION ERROR OR RUNTIME ERROR OR SOME TIME WRONG ANSWER PLZ CAN SOME ONE HELP ME.
MY CODE IS
import java.io.DataInputStream;
import java.io.IOException;
public class Main
{
public static void main(String[] args) throws IOException
{
DataInputStream in =new DataInputStream(System.in);
String s;
char[] str;
int c=Integer.parseInt(in.readLine());
while (c>0)
{
s=in.readLine();
str=s.toCharArray();
int i =0;
int count=0;
while(i<str.length)
{
if((str[i]=='A')||(str[i]=='D')||(str[i]=='O')||(str[i]=='P')||(str[i]=='R'))
{
count=count+1;
}
else
if(str[i]=='B')
{
count=count+2;
}
i++;
}
c--;
System.out.println(count);
}
System.exit(0);
}
}