Question: Code in java - Write method called SumDigits which takes an integer as a parameter, sums the digits of the number and retums the sum.
- Write method called SumDigits which takes an integer as a parameter, sums the digits of the number and retums the sum. - The method signature is: public static int SumDigits(int n ) - You will need to use % to determine the specific digit and/to remove the digit from right to left. - Example output: 234 - 4+3+2=9 - The Math behind this: 234%10=4234/10=2323%10=323/10=223%10=22/10=0
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
