Question
JAVA Design and implement a program (name it SumDigits) to compute the sum of all digits in an integer number. The program defines the following
JAVA
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
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started