How can I have calculate totals for input into a table?