Question: Exercise #1: Design and implement a program (name it SumDigits) to compute the sum of all digits in an integer number. The program defines the

Exercise #1: Design and implement a program (name it SumDigits) to compute the sum of all digits in an integer number. The program defines the following method:

Method sumDigits (int number) returns the sum of all digits in number.

In the main method, prompt the user for an integer input and pass the input to method sumDigits() to obtain the sum of its digits. Then display the entered number followed by the sum of its digits as shown below. Document your code and properly label the input prompt and the outputs as shown below.

Sample run 1:

You entered: 12345

Sum of digits: 15

Sample run 2:

You entered: 78501

Sum of digits: 21

Sample run 3:

You entered: 9000

Sum of digits: 9

C++

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!