Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a program that will take an integer and add up each of the numbers digits. You must use a while loop and % to

Write a program that will take an integer and add up each of the numbers digits. You must use a while loop and % to access each of the individual digits. Use / to reduce the number so that you can sum all of the digits.

digit adder shell:

import static java.lang.System.*;

public class DigitAdder { public static int sumDigits( int number ) { int sum=0; return sum; } }

digit adder runner shell:

import static java.lang.System.*;

public class DigitAdderRunner { public static void main( String args[] ) { //add test cases } }

sample data:

234

10000

111

9005

84645

8547

123456789

sample output:

9 is the sum of the digits of 234

1 is the sum of the digits of 10000

3 is the sum of the digits of 111

14 is the sum of the digits of 9005

27 is the sum of the digits of 84645

24 is the sum of the digits of 8547

45 is the sum of the digits of 123456789

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Practical Azure SQL Database For Modern Developers Building Applications In The Microsoft Cloud

Authors: Davide Mauri, Silvano Coriani, Anna Hoffma, Sanjay Mishra, Jovan Popovic

1st Edition

1484263693, 978-1484263693

More Books

Students also viewed these Databases questions

Question

How many Tables Will Base HCMSs typically have? Why?

Answered: 1 week ago

Question

What is the process of normalization?

Answered: 1 week ago