You already have a totalnumber variable. Just initialize that to 0 and then each loop add whatever the person entered to that variable.