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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!