holes in the text ..why it is showing wrong answer??

import java.util.*;
class MAIN {
public static void main(String[] args) {

Scanner obj=new Scanner(System.in);
int k=obj.nextInt();

String m[]=new String[k];
int m2[]=new int[k];

int z=0;
for(int i=0;i<=k-1;i++)
m[i]=obj.next();

for(int i=0;i<=k-1;i++)
{
z=0;
for(int j=0;j<=m[i].length()-1;j++)
{
if(m[i].charAt(j)==‘A’ || m[i].charAt(j)==‘D’ || m[i].charAt(j)==‘O’ || m[i].charAt(j)==‘P’|| m[i].charAt(j)==‘R’)
{
++z;
m2[i]=z;
}

if(m[i].charAt(j)=='B')
{
z=z+2;
	m2[i]=z;
}

}
}

for(int i=0;i<=k-1;i++)
System.out.println(m2[i]);

}

}

‘Q’ also has one hole!

2 Likes

Please accept the answer once you got what you have got what you needed!!

Happy Coding

thanx pranjalranjan… :slight_smile:

1 Like