Question: Why this code always return 0

```
public int loveCal(String bname, String gname) {

    char[] boy_name = bname.toLowerCase().toCharArray();
    char[] girl_name = gname.toLowerCase().toCharArray();

    int boy = 0;
    int girl = 0;
    int love = 0;

    for(int i = 0; i < bname.length(); i++)
        boy += (int) boy_name[i];
    for(int i = 0; i < gname.length(); i++)
        girl += (int) girl_name[i];

    if( boy > girl )
        love = (girl/boy)*100;
    else
        love = (boy/girl)*100;

    return love;
}

```

Answer: 
You probably need to do floating point calculations or maybe just change the order, to avoid rounding intermediate results down to 0 when everything is done with integers.

```
 return 100.0 * girl / boy;  // using floating points

 // or maybe just

 return 100 * girl / boy;    // using int, but multiplying first

```
It's because of this division:

```
  (girl/boy)

```

Using int, if this results in a fractionary number, returned int will be 0.
Use floats or double instead.