there may be other tokens which not matching with your if conditions check below code
public static void main(String [] args) throws IOException
{
Scanner inFile = new Scanner(new File("MaleFemaleInFamily.txt"));
String token = "";
int counter = 0;
int girlAndBoy = 0;
int twoBoys = 0;
int twoGirls = 0;
int other = 0;
while(inFile.hasNext())
{
token = inFile.next();
System.out.println(counter + "\t" + token + " ");
if(token.equals("GB"))
{
girlAndBoy++;
}
else if(token.equals("BB"))
{
twoBoys++;
}
else if(token.equals("GG"))
{
twoGirls++;
}else
{
other++;
}
counter++;
}
int gbPercent = (girlAndBoy * 100) / counter;
int bbPercent = (twoBoys * 100) / counter;
int ggPercent = (twoGirls * 100) / counter;
int otherPercent = (other * 100) / counter;
System.out.println("\n");
System.out.println("GB: " + girlAndBoy + " \\ " + gbPercent + "%");
System.out.println("BB: " + twoBoys + " \\ " + bbPercent + "%");
System.out.println("GG: " + twoGirls + " \\ " + ggPercent + "%");
System.out.println("Other: " + other + " \\ " + otherPercent + "%");
System.out.print("GB + " + "BB + " + "GG " + "OTHER" + "= ");
System.out.println(girlAndBoy + twoBoys + twoGirls +other);
inFile.close();
}