Computer Science Canada Addition of Digits in integer |
Author: | Caceres [ Wed Jul 12, 2006 10:42 pm ] | ||
Post subject: | Addition of Digits in integer | ||
Hello, I was just wondeirng how to add the digits of an integer. For example:
I'm basically curious into how to add up the sums of digits of an integer. I wa wondering if the sum_two and the part to follow will work. Would i have to put int two = (sin.charAt(1)-48)*2. Thanks. P.S Sorry if this is unclear ~Caceres |
Author: | wtd [ Wed Jul 12, 2006 11:30 pm ] | ||
Post subject: | |||
There's a mathematical way of doing this. Since I don't like just giving out easy answers...
|
Author: | Caceres [ Thu Jul 13, 2006 10:13 pm ] |
Post subject: | |
For my previous code. It keeps saying Quote: int cannot be dereference
Anyone know what this means? |
Author: | Caceres [ Thu Jul 13, 2006 10:28 pm ] |
Post subject: | |
For my previous code. It keeps saying Quote: int cannot be dereference
Anyone know what this means? |
Author: | [Gandalf] [ Thu Jul 13, 2006 11:00 pm ] |
Post subject: | |
It means that an int is not an object, and therefore cannot be treated as such. An Integer, however... |