Question: (The code must be done in Java.) Find the sum of digits of a positive integer number Sum = number itself if (number is a
(The code must be done in Java.)
Find the sum of digits of a positive integer number
Sum = number itself if (number is a single digit)
otherwise sum = the last digit of the number + the sum of rest of the digits of thenumber.
public int sumOfDigits(int number)
Test this method with following input numbers:
0,101,1,231214,734
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
