I would like to write a function that will be reverse a number and then sum it up. 
For example, the input string is 

> 
> We have 55 guests in room 38
> 
> 
> 

So the expected output should be

```
83 + 55 = 138

```

I have face a question is that I can't read the last number
example:
input string is '8 people'
output is 0

Here's the code I've written :

```
int total = 0;
String num = "";
String a = input.nextLine();

for (int i = a.length() - 1; i > 0; i--) {
    if (Character.isDigit(a.charAt(i))) {
        num += a.charAt(i);

        if (!Character.isDigit(a.charAt(i - 1))) {
            total += Integer.valueOf(num);
            num = "";
        }
    }
}

```