![subject](/tpl/images/cats/informatica.png)
Computers and Technology, 06.03.2020 21:57 lizzieee51
6.2 Sum the digits in an integer (Sum the digits in an integer) Write a method that computes the sum of the digits in an integer. Use the following method header: public static int sumDigits(long n) For example, sumDigits(234) returns 9 (= 2 + 3 + 4). (Hint: Use the % operator to extract digits and the / operator to remove the extracted digit. For instance, to extract 4 from 234, use 234 % 10 (= 4 ). To remove 4 from 234, use 234 / 10 (= 2 3 ). Use a loop to repeatedly extract and remove the digit until all the digits are extracted. Write a test program that prompts the user to enter an integer then displays the sum of all its digits. So in your main method you'd call sumDigits() like this and print what it returns. For example: System. out. println("Sum of the digits in the number 1234 is: " + sumDigits(1234));
![ansver](/tpl/images/cats/User.png)
Answers: 2
![](/tpl/images/ask_question.png)
![](/tpl/images/ask_question_mob.png)
Other questions on the subject: Computers and Technology
![image](/tpl/images/cats/informatica.png)
Computers and Technology, 22.06.2019 23:30, keviongardner
The next button in the review section shows the next available comment. next slide with no comment. previous comment. edited comment.
Answers: 1
![image](/tpl/images/cats/informatica.png)
![image](/tpl/images/cats/informatica.png)
Computers and Technology, 24.06.2019 00:10, roxymiller3942
Read each statement below. if the statement describes a peer-to-peer network, put a p next to it. if the statement describes a server-based network, put an s next to it. p - peer-to-peer s - server-based
Answers: 1
![image](/tpl/images/cats/informatica.png)
Computers and Technology, 24.06.2019 01:00, bellamyciana
What are two ways to access the options for scaling and page orientation? click the home tab, then click alignment, or click the file tab. click the file tab, then click print, or click the page layout tab. click the page layout tab, or click the review tab. click the review tab, or click the home tab?
Answers: 2
You know the right answer?
6.2 Sum the digits in an integer (Sum the digits in an integer) Write a method that computes the sum...
Questions in other subjects:
![Konu](/tpl/images/cats/informatica.png)
Computers and Technology, 14.09.2019 08:30
![Konu](/tpl/images/cats/mat.png)
![Konu](/tpl/images/cats/informatica.png)
Computers and Technology, 14.09.2019 08:30
![Konu](/tpl/images/cats/mat.png)
Mathematics, 14.09.2019 08:30
![Konu](/tpl/images/cats/informatica.png)
Computers and Technology, 14.09.2019 08:30
![Konu](/tpl/images/cats/himiya.png)
![Konu](/tpl/images/cats/himiya.png)
Chemistry, 14.09.2019 08:30
![Konu](/tpl/images/cats/informatica.png)
Computers and Technology, 14.09.2019 08:30
![Konu](/tpl/images/cats/mat.png)