Question: Write the code for sumDigitsInNumber(int number). The method takes a three-digit whole number . You need to calculate the sum of the digits of this

Write the code for sumDigitsInNumber(int number). The method takes a three-digit whole number. You need to calculate the sum of the digits of this number, and then return the result.

Consider this example: The sumDigitsInNumber method is called with the argument 321. Output 6. Please note that The sumDigitsInNumber method must return the sum of all digits in the parameter number.

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!